Prøver at poste mit problem en gang mere herinde og håber på at nogen ser det og kan løse det
Det drejer sig om oprettelse af bruger samt en aktiveringskode der bliver tilsendt på mail.
Login systemet virkede fint før jeg tilføjede den del med aktiveringskoden der skal tilsendes på mail. Ved ikke hvad det er der går galt
Har følgende kode på den php sider der bliver henvist til fra min html form:
$activationKey = mt_rand() . mt_rand() . mt_rand() . mt_rand() . mt_rand();
$profiletype = $_POST["profiletype"];
$password = $_POST["password"];
$repeat = $_POST["repeat"];
$firstname = $_POST["firstname"];
$lastname = $_POST["lastname"];
$country = $_POST["country"];
$cityname = $_POST["cityname"];
$postalcode = $_POST["postalcode"];
$streetname = $_POST["streetname"];
$streetnumber = $_POST["streetnumber"];
$errorCount = "0";
$email = $_POST['email'];
$tjek = sprintf("SELECT email FROM users WHERE email ='%s'", mysql_real_escape_string($_POST['email']));
$resultat = mysql_query($tjek);
if($profiletype == "")
{
echo "Please, choose your profiletype<br>";
$errorCount++;
}
if($email == "")
{
echo "Please, enter your email adress (your username)<br>";
$errorCount++;
}
if($password == "")
{
echo "Please, enter a password<br>";
$errorCount++;
}
if($repeat == "" || $repeat != $password)
{ echo "Your passwords don't match, please enter them carefully<br>";
$errorCount++;
}
if($firstname == "")
{
echo "Please, enter your first name<br>";
$errorCount++;
}
if($lastname == "")
{
echo "Please, enter your first name<br>";
$errorCount++;
}
if($country == "")
{
echo "Please, choose your country from the list<br>";
$errorCount++;}if($cityname == "")
{
echo "Enter your city's name<br>";
$errorCount++;
}
if($postalcode == "")
{
echo "Enter your postal code<br>";
$errorCount++;
}
if($streetname == "")
{
echo "Enter your street's name<br>";
$errorCount++;
}
if($streetnumber == "")
{
echo "Enter the number of your street where you live<br>";
$errorCount++;
}
if($errorcount == 0)
{
if(mysql_num_rows($resultat) == 0)
{
mysql_connect("****","****","****");
mysql_select_db("****");
$password = MD5($password);
$insert = mysql_query("INSERT INTO users (profiletype,email,password,firstname,lastname,country,cityname,postalcode,streetname,streetnumber,activationkey,status) VALUES ('$profiletype','$email','$password','$firstname','$lastname','$country','$cityname','$postalcode','$streetname','$streetnumber','$activationKey', 'verify')");
if (!mysql_query($insert))
{
die('Error: ' . mysql_error());
}
echo "An email has been sent to $_POST[email] with an activation key. Please check your mail to complete registration.";
$to = $_POST[email];
$subject = " blabla.net Registration";
$message = "Welcome to blabla Net! \r\r You, or someone using your email address, has completed registration at blabla.net. You can complete registration by clicking the following link:\rhttp://www.blabla.net/brugeroprettelse/verify.php?$activationKey\r\r If this is an error, ignore this email and you will be removed from our mailing list.\r\r Regards,\ blabla.net";
$headers = 'From: noreply@blabla.net' . "\r\n" .
'Reply-To: noreply@blabla.net' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
}
else
{
if ($_SERVER['QUERY_STRING'])
{
$queryString = $_SERVER['QUERY_STRING'];
$query = "SELECT * FROM users";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result))
{
if ($queryString == $row["activationkey"])
{
echo "Congratulations!" . $row["firstname"] . " " . $row["lastname"] . " is now the proud new owner of a blabla.net account.";
$insert="UPDATE users SET activationkey = '', status='activated' WHERE (id = $row[id])";
if (!mysql_query($insert))
{
die('Error: ' . mysql_error());
}
}
}
}
else
{
echo "The username/email you have entered is not available!";
}
}
}
else
{
echo "Go back";
}
Får denne fejl meddelelse:
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1
Indlæg senest redigeret d. 04.08.2010 11:01 af Bruger #15621