Associate
- Joined
- 21 Sep 2007
- Posts
- 453
So I am setting up some security on a message board I am making. Users will receive an email containg a link that will activate their message and be viewable on the website.
I can do the emails, add data to the DB etc, but my status changing code page has a bug.
When I use the following code, its broken, as in the header shows, but nothing else. no error messages, no confirmation text, no footer.
When I comment out the $url variable, my code will work, as in, can send an email (minus the URL link ofc) and can add data to the DB.
Any ideas? I tried placing the $url in various places, but that didnt help.
I can do the emails, add data to the DB etc, but my status changing code page has a bug.
When I use the following code, its broken, as in the header shows, but nothing else. no error messages, no confirmation text, no footer.
PHP:
<?php
session_start();
include 'includes/header.php';
$number = $_POST['txtNumber'];
$url = 'http://www.website.co.uk/test/get.php?postID='.md5($email).'&stamp='.base64_encode(NOW());
if (md5($number) == $_SESSION['image_random_value']) {
include 'includes/config.php';
include 'includes/opendb.php';
$email=$_POST['email'];
$name=$_POST['name'];
$website=$_POST['website'];
$location=$_POST['location'];
$message=$_POST['message'];
// Just to be safe, I strip out HTML tags
//$realname = strip_tags($realname);
//$email = strip_tags($email);
$message = strip_tags($message);
// set the variables
// replace [email protected] with your email
$sendto = "[email protected]";
$subject = "Sending Email Feedback From My Website";
$email_message = "$name\n\n$email\n\n$message\n\nPlease click the following link in order to activate your forum post\n\n$url";
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$status = "OK"; // setting the flag for form validation
$msg=""; // error message string is blank
// now let us check email address
if (!stristr($email,"@") OR !stristr($email,".")) {
$msg="<center>Your email address is not correct</center><BR>";
$status="NOT OK";
}
// Now let us check if name is entered or not
if(strlen($name) < 2 ){ // if name is less than two char length
$msg .="<center>Please enter your name</center><BR>";
$status="NOT OK";
}
if($status<>"OK"){ // if form validation is not passed
echo "<BR><BR>";
echo $msg. "<br><center><input type='button' value='Retry' onClick='history.go(-1)'></center><br><br><br>";
} else {
// send the email
mail($sendto, $subject, $email_message, $headers);
// adding data to mysql database
$rt=mysql_query("insert into forum(name, email, website, location, message, post_time) values('$name','$email','$website','$location','$message', NOW())");
echo mysql_error();
echo "<center><font face='Verdana' size='2'>Entry added, Thank You. <a href=forum.php>Click here to view entries</a>. </font></center><br><br><br>";
}
}
?>
When I comment out the $url variable, my code will work, as in, can send an email (minus the URL link ofc) and can add data to the DB.
Any ideas? I tried placing the $url in various places, but that didnt help.