jd2007 Posted July 14, 2007 Share Posted July 14, 2007 <?php /*Use of Sessions*/ if(!session_id()) session_start(); header("Cache-control: private"); //avoid an IE6 bug (keep this line on top of the page) //function validateEmail($email) //{ // return ereg("^[a-zA-Z0-9\_\-\.]+@[a-zA-Z]+\.[a-zA-Z\.\-]+$", $email); //} if (isset($_POST['nickname']) && isset($_POST['password']) && isset($_POST['cpass']) && isset($_POST['email'])) { if (isset($_POST['password']) == isset($_POST['cpass'])) { if (ereg("^[a-zA-Z0-9\_\-\.]+@[a-zA-Z]+\.[a-zA-Z\.\-]+$",($_POST['email']))) { /*Connection to database logindb using your login name and password*/ $db=mysql_connect('localhost','root') or die(mysql_error()); mysql_select_db('Vote'); /*additional data checking and striping*/ $_POST['nickname']=mysql_real_escape_string(strip_tags(trim($_POST['login']))); $_POST['cpass']=mysql_real_escape_string(strip_tags(trim($_POST['cpass']))); mysql_query("INSERT INTO Users SET nickname='{$_POST['nickname']}',cpass='{$_POST['cpass']}'",$db); if(mysql_affected_rows() > 0) { $_SESSION['nickname'] = $_POST['nickname']; $to = isset($_POST['email']); $subject = 'Voting User Confirmation'; $headers = "MIME-Version: 1.0rn"; $headers.= "Content-type: text/html; charset=iso-8859-1rn"; $message=" <img> <b>You are one step away to cast your vote.<br> Click the link below to confirm your registration.<br><br> <a href='login.php'>Confirm !</a> </b>"; $mail_sent=mail( $to, $subject, $message, $headers ); echo $mail_sent ? "A confirmation mail has been sent to your e-mail address. Please click the link which is provided." : "We're sorry, sending confirmation mail failed. "; } else { $nickname= 'Please choose another nickname.'; echo $nickname; exit; } } else { echo "Please enter a valid e-mail."; //echo "<style></style>"; //echo "<img src='' class=''>"; echo "<form method='post' action='registration.php'> Nickname: <input type='text' name='nickname'> Password: <input type='password' name='password'> Confirm Password: <input type='password' name='cpass'> E-mail: <input type='text' name='email'> <input type='submit' value='Register'> </form>"; exit; } } else if (isset($_POST['password']) != isset($_POST['cpass'])) { echo "Passwords does not match."; echo "<style></style>"; echo "<img src='' class=''>"; echo "<form method='post' action='registration.php'> Nickname: <input type='text' name='nickname'> Password: <input type='password' name='password'> Confirm Password: <input type='password' name='cpass'> E-mail: <input type='text' name='email'> <input type='submit' Register'> </form>"; exit; } else {} } else if (!isset($_POST['nickname']) || !isset($_POST['password']) || !isset($_POST['cpass']) || !isset($_POST['email'])) { echo "Please fill in all fields."; echo "<form method='post' action='registration.php'> Nickname: <input type='text' name='nickname'> Password: <input type='password' name='password'> Confirm Password: <input type='password' name='cpass'> E-mail: <input type='text' name='email'> <input type='submit' value='Register'> </form>"; exit; } else {} ?> what's wrong in the above code ... i get this error: Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\AppServ\www\Voting\registration.php on line 51 Quote Link to comment Share on other sites More sharing options...
metrostars Posted July 14, 2007 Share Posted July 14, 2007 $headers = "From: example@fromdomain.com "; $headers .= "MIME-Version: 1.0rn "; $headers.= "Content-type: text/html; charset=iso-8859-1rn"; Quote Link to comment Share on other sites More sharing options...
bluebyyou Posted July 14, 2007 Share Posted July 14, 2007 Can you use more descriptive titles please, you use the same title for every topic. Quote Link to comment Share on other sites More sharing options...
jd2007 Posted July 14, 2007 Author Share Posted July 14, 2007 i get this : Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\AppServ\www\Voting\registration.php on line 51 We're sorry, sending confirmation mail failed. Quote Link to comment Share on other sites More sharing options...
metrostars Posted July 14, 2007 Share Posted July 14, 2007 You have to have mail server installed on your testingf server, if you do, then go to your PHP.ini file and search for the bit in it and set it to this: [mail function] ; For Win32 only. SMTP = localhost smtp_port = 25 ; For Win32 only. ;sendmail_from = example@example.co.uk Quote Link to comment Share on other sites More sharing options...
LiamProductions Posted July 14, 2007 Share Posted July 14, 2007 Try using more descriptive titles in the future. And what PHP version do you have Quote Link to comment Share on other sites More sharing options...
jd2007 Posted July 14, 2007 Author Share Posted July 14, 2007 are u a programmer or are u just learning php ? i'm using PHP Script Language Version 5.2.1 Quote Link to comment Share on other sites More sharing options...
jd2007 Posted July 14, 2007 Author Share Posted July 14, 2007 [mail function] ; For Win32 only. SMTP = localhost smtp_port = 25 ; For Win32 only. ;sendmail_from = me@example.com .....is already there...what to do ? Quote Link to comment Share on other sites More sharing options...
metrostars Posted July 14, 2007 Share Posted July 14, 2007 Youy musn't have a mail server installed on your machine, you'll have to get one. I recommend http://www.mailenable.com/download.asp the standard version. It's free, and doesn't take up much in the way of resources, and easy to use. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.