PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I need to send several variable from a form to a php page. It sends me an errors message that I set , if agree was not checked. Here is the link http://www.tandembyte.com/register.html I think the problem is getting the php file to notice that the check box was checked.?
the problem is the fact that you are refrencing the objects document.form1.elements["agree"].value and thats not the way to go. use document.form1.elements["agree"].checkedto send a true or false value to PHP and this is very important: PHP wont access them as booleans but as strings so :
please make sure you agree with the terms of use before continuing, which I set if the check box was not checked. But when I check it, this error pops up.
<?php
include ('*****.php');
$testfname = $_POST['fname'];
$testlname = $_POST['lname'];
$testpassword = $_POST['password'];
$testpassword2 = $_POST['password2'];
$testemail = $_POST['email'];
$testemail2 = $_POST['email2'];
$operating = $_POST['os'];
//make sure user agrees to T.O.S.
if ($_POST['agree'] == "true") {
//test for duplicate email
$query = "SELECT * FROM ***** WHERE email='$testemail'";
$result = mysql_query($query);
$num = mysql_num_rows($result);
if ($num == 0) {
//make sure emails and passwords match up
if (($testpassword == $testpassword2) && ($testemail == $testemail2)) {
//create random code
$confirm_code = md5(uniqid(rand()));
//strip fields of spaces
$fname = strip_tags($testfname);
$lname = strip_tags($testlname);
$password = strip_tags($testpassword);
$email = strip_tags($testemail);
//insert into database
$sql = "INSERT INTO **** SET code='$confirm_code', fname='$fname', lname='$lname', password='$password', email='$email', system='$operating'";
$result = mysql_query($sql);
if ($result) {
$message.= "Your confirmation link \r\n";
$message.= "Click on this link to activate your account \r\n";
$message.= "http://www.tandembyte.com/php/activated.php?passkey=$confirm_code\r\n";
$message.= "Email: $email\r\n";
$message.= "Password: $password";
$sentmail=mail("$email",'Registration Conformation',"$message");
}
// if your email succesfully sent
if($sentmail){
header("Location:../confirmation.html");
}
else {
echo "Unable to send confirmation link to your e-mail address";
}
}
else {
echo "Either password or email do not match!";
}
}
else {
echo "This email is already in use";
}
}
else {
echo "please make sure you agree with the terms of use before continuing"; }
?>
Last edited by Benjamin on Sat May 09, 2009 11:15 am, edited 1 time in total.
Reason:Changed code type from text to php.
OK that worked. but when it tries to send the confirmation email, it errors there. I took a look at my database, and saw that the only variable being sent was fname.
Maybe this is not true in your case but watch out what JS sends as boolean true or false, I noticed on the library I used that it sends the STRING "true".
var_dump( $_POST ) to be double sure esp with Ajax.