Log in

View Full Version : Simple php form help



sakib000
03-06-2008, 06:04 PM
thanks for helping me :) guys. here is my basic sendmail.php


<?php
$from = 'test@testing.threadpunk.com';
$to = 'sakib.live@gmail.com';
$subject = "Product order at angross.com";
$plan = $_POST['product'];
$extrapages = $_POST['additional'];
$purpose = $_POST['mainpurpose'];
$visitordetails = $_POST['visitorsdetails'];
$youlike = $_POST['sitesyoulike'];
$dontlike = $_POST['sitesyoudontlike'];
$colortheme = $_POST['colorguides'];
$adddetails = $_POST['details'];
$logopref = $_POST['logo'];
$fname = $_POST['firstname'];
$lname = $_POST['lastname'];
$comname = $_POST['companyname'];
$mailadd1 = $_POST['email1'];
$mailadd2 = $_POST['email2'];
$pass1 = $_POST['password'];
$pass2 = $_POST['password2'];
$phonenumber = $_POST['phone'];
$straddress = $_POST['streetaddress'];
$cityname = $_POST['city'];
$statename = $_POST['state'];
$zip = $_POST['postal'];
$name = $_POST['country'];
$howfind = $_POST['howfindus'];

foreach($_POST['check'] as $value) {
$check_msg .= "Checked: $value\n";
}

mail("$to", "$subject", "$plan \n $extrapages \n $purpose \n $visitordetails \n $youlike \n $dontlike \n $sitesyoudontlike \n $colortheme \n $adddetails \n $logopref \n $fname \n $lname \n $comname \n $mailadd1 \n $mailadd2 \n $pass1 \n $pass2 \n $phonenumber \n $straddress \n $cityname \n $statename \n $zip \n $name \n $howfind \n $check_msg","From:$from");

?>

Can someone please configure it to check whether two email fields and two password fields are same or not. if OK script just send a mail, if not OK script just display error message that email fields are not same or password fields are not same. Actually user need to re enter email and password

one more thing, mail client inbox is showing 'from' correctly but send-by is hostgator.com. I don't even know this little thing :confused:

Thanks

city_coder
03-07-2008, 09:41 AM
Boogyman showed you the strcmp before didnt he?


if(strcmp($mailadd1,$mailadd2)!=0) {
//dont match
$error = 1;
$errordetails = 1;
header('Location: http://www.mewan.net/mark/css/submitpage.php?&error=1&errordetails=1');
} else {
//matched emails
if(strcmp($pass1,$pass2)!=0) {
//didnt match passwords
$error = 1;
$errordetails = 2;
header('Location: http://www.mewan.net/mark/css/submitpage.php?&error=1&errordetails=2');
} else {
//dont know the code to do the email processing bit sorry.
}

and in your submit page you would have


if(isset($error)) {
if($errordetails == '1') {
$errormsg = 'You did not enter the same email address';
} else {
$errormsg = 'You did not enter the same password';
}
echo '<div>'.$errormsg.'</div>';
}


Note: You cannot start outputting information before you use the header function. It wont redirect to the page. I.E. make sure that this part of the code is right at the top of your page.

Iv just tested this so it should work, iv done it before in JSP, but then i did it with an errors page which would read the session that i set before i redirected to the page, but this way works. If you want an errors page, you can have that, its just the same code really.