eschuppe Posted April 13, 2009 Share Posted April 13, 2009 Hello everyone, I've been using $message to post an error if there is one however when I hit registers on the form it returns a blank page.. I'm stuck i've beenusing this method on several other pages and it works fine. Also, if I post errors through header it works but I don't want to post that way since it wont match the look of other pages. Aside from header, it works if I change from printing from variable to just die it works perfectly fine. However, I do not want it to clear the form I want it to print the error above the form. Any idea why this is not working? the URL is www.ericschuppe.com/register.php <?php session_start(); include ('dbc.php'); if ($_POST['Submit'] == 'Register') { if (strlen($_POST['full_name']) < 1) { $message .= '<p>Incorrect email, please enter valid email address.</p>'; } if (strlen($_POST['email']) < 5) { $message .= '<p>Incorrect email, please enter valid email address.</p>'; } if (strcmp($_POST['pass1'],$_POST['pass2']) || empty($_POST['pass1']) ) { $message .= '<p>Password does not match or empty.</p>'; } if (strlen($_POST['user_idnum']) < 4) { $message .= '<p>Incorrect ID number. Please enter a valid ID number.</p>'; } if (strcmp(md5($_POST['user_code']),$_SESSION['ckey'])) { $message .= '<p>Invalid code entered. Please enter the correct code as shown in the Image.</p>'; } $rs_duplicates = mysql_query("SELECT id FROM users WHERE user_email='$_POST[email]'"); $duplicates = mysql_num_rows($rs_duplicates); if ($duplicates > 0) { //die ("ERROR: User account already exists."); $message .= '<p>User account already exists, Try Again.</p>'; } $rs_duplicates_id = mysql_query("SELECT id FROM users WHERE user_idnum='$_POST[user_idnum]'"); $duplicates_id = mysql_num_rows($rs_duplicates_id); if ($duplicates_id > 0) { $message .= '<p>Student ID already exists, Try Again.</p>'; exit(); } $md5pass = md5($_POST['pass2']); $activ_code = rand(1000,9999); $server = $_SERVER['HTTP_HOST']; $host = ereg_replace('www.','',$server); mysql_query("INSERT INTO users (`user_email`,`user_pwd`,`user_idnum`,`joined`,`activation_code`,`full_name`) VALUES ('$_POST[email]','$md5pass','$_POST[user_idnum]',now(),'$activ_code','$_POST[full_name]')") or die(mysql_error()); unset($_SESSION['ckey']); echo("Registration Successful! An activation code has been sent to your email address with an activation link..."); exit; } if (isset($message)) { echo '<font color="red">', $message, '</font>'; } ?> <link href="styles.css" rel="stylesheet" type="text/css"> <?php if (isset($_GET['msg'])) { echo "<div class=\"msg\"> $_GET[msg] </div>"; } ?> <p> </p> <table width="65%" border="0" cellpadding="0" cellspacing="0"> <tr> <td class="mnuheader"><strong><font size="5">Register Account</font></strong></td> </tr> <tr> <td class="forumposts"><form name="form1" method="post" action="register.php" style="padding:5px;"> <p><br> Name: <input name="full_name" type="text" id="full_name"> </p> <p>Email: <input name="email" type="text" id="email"> </p> <p>Password: <input name="pass1" type="password" id="pass1"> Atleast 5 characters</p> <p>Retype Password: <input name="pass2" type="password" id="pass2"> </p> <p> ID Number: <input name="user_idnum" type="text" id="user_idnum"> </p> <p> <input name="user_code" type="text" size="10"> <img src="pngimg.php" align="middle"> </p> <p align="center"> <input type="submit" name="Submit" value="Register"> </p> </form></td> </tr> </table> <div align="left"></div> </body> </html> Thanks ahead of time. Link to comment https://forums.phpfreaks.com/topic/153802-returning-errors/ Share on other sites More sharing options...
MasterACE14 Posted April 13, 2009 Share Posted April 13, 2009 change this... <?php if (isset($message)) { echo '<font color="red">', $message, '</font>'; } to this... <?php if (isset($message)) { echo '<font color="red">'.$message.'</font>'; } Link to comment https://forums.phpfreaks.com/topic/153802-returning-errors/#findComment-808355 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.