lukeawade Posted September 10, 2008 Share Posted September 10, 2008 The PROBLEM is I need to display two different error messages based on the information in one textfield. If there is nothing in the textfield it shows an error based on the tNG_formvalidation(WORKS), the second error shows if their email already exists in the database(DOESNT WORK) Here is where i create the email error if its in the database already <?php if (isset($_POST['email'])) { $email = trim($_POST['email']); $emailError = false; $query = "SELECT * FROM users WHERE email = '$email'"; $result = mysql_query($query) or die (mysql_error()); if (mysql_num_rows($result)!== 0) { $emailError = "That email address has already been registered."; } //Error exists, reformat values for repopulating fields $email = stripslashes($email); } ?> NOW how do I display that under the Textfield/Input when there is already an echo error?? <head> <?php echo $tNGs->displayValidationRules();?> </head> <body> <form name="testForm" method="POST"> <input name="email" type="text" id="email" value="<?php echo $row_rsdashboard_registration['email']; ?>" size="32" /> <?php echo $tNGs->displayFieldError("dashboard_registration", "email"); ?> <button type="submit">Submit Data</button> </form> </body> Link to comment https://forums.phpfreaks.com/topic/123683-expert-needed/ Share on other sites More sharing options...
DarkWater Posted September 10, 2008 Share Posted September 10, 2008 Just echo it out normally...? o_O Did you just try echo $emailError;? Link to comment https://forums.phpfreaks.com/topic/123683-expert-needed/#findComment-638682 Share on other sites More sharing options...
lukeawade Posted September 10, 2008 Author Share Posted September 10, 2008 Like this? I wasnt sure if you could put two echo's or two snippets of code in one braquet? <head> <?php echo $tNGs->displayValidationRules();?> </head> <body> <form name="testForm" method="POST"> <input name="email" type="text" id="email" value="<?php echo $row_rsdashboard_registration['email']; ?>" size="32" /> <?php echo $tNGs->displayFieldError("dashboard_registration", "email"); echo $emailError;?> <button type="submit">Submit Data</button> </form> </body> Link to comment https://forums.phpfreaks.com/topic/123683-expert-needed/#findComment-638697 Share on other sites More sharing options...
lukeawade Posted September 10, 2008 Author Share Posted September 10, 2008 What do i put as the value for the input? Link to comment https://forums.phpfreaks.com/topic/123683-expert-needed/#findComment-638699 Share on other sites More sharing options...
lukeawade Posted September 10, 2008 Author Share Posted September 10, 2008 This is what I tried and it sent me to a blank page with this error: "No database selected" PRECODE <?php if (isset($_POST['email'])) { $email = trim($_POST['email']); $emailError = false; $query = "SELECT * FROM users WHERE email = '$email'"; $result = mysql_query($query) or die (mysql_error()); if (mysql_num_rows($result)!== 0) { $emailError = "That email address has already been registered."; } //Error exists, reformat values for repopulating fields $email = stripslashes($email); $colname_rsMail = $_POST['email']; }?> MY CODE IN MY BODY <input name="email" type="text" id="email" value="<?php echo $row_rsdashboard_registration['email']; echo $email;?>" size="32" /> <?php echo $tNGs->displayFieldError("dashboard_registration", "email"); echo $emailError;?></div></td> Link to comment https://forums.phpfreaks.com/topic/123683-expert-needed/#findComment-638704 Share on other sites More sharing options...
DarkWater Posted September 10, 2008 Share Posted September 10, 2008 I'm 95% sure that it means that you forgot to select a database, but I could just be naive. Link to comment https://forums.phpfreaks.com/topic/123683-expert-needed/#findComment-638708 Share on other sites More sharing options...
lukeawade Posted September 10, 2008 Author Share Posted September 10, 2008 Hahhaah really? I had no idea. Here is what I tried. Still doesnt work. <?php $colname_rsMail = "-1"; if (isset($_POST['email'])) { $colname_rsMail = $_POST['email']; mysql_select_db($database_connRegistration, $connRegistration); $query_email = sprintf("SELECT email FROM dashboard_registration WHERE email = '$email'"); //$query = "SELECT email FROM dashboard_registration WHERE email = '$email'"; $email = mysql_query($query_email, $connRegistration) or die(mysql_error()); //$email = trim($_POST['email']); $emailError = false; if (mysql_num_rows($email)!== 0) { $emailError = "That email address has already been registered."; } //Error exists, reformat values for repopulating fields $email = stripslashes($email); }?> Link to comment https://forums.phpfreaks.com/topic/123683-expert-needed/#findComment-638709 Share on other sites More sharing options...
DarkWater Posted September 10, 2008 Share Posted September 10, 2008 1) Is $database_connRegistration set? 2) What errors does it give now (if any)? Link to comment https://forums.phpfreaks.com/topic/123683-expert-needed/#findComment-638710 Share on other sites More sharing options...
EchoFool Posted September 10, 2008 Share Posted September 10, 2008 put or die(mysql_error()); after your queries and also error reporting on ALL so you know that your variables are set. Link to comment https://forums.phpfreaks.com/topic/123683-expert-needed/#findComment-638717 Share on other sites More sharing options...
DarkWater Posted September 10, 2008 Share Posted September 10, 2008 put or die(mysql_error()); after your queries and also error reporting on ALL so you know that your variables are set. If you read his code, you'd notice that he has that error-checking in place, which is why he got to see that MySQL error. Link to comment https://forums.phpfreaks.com/topic/123683-expert-needed/#findComment-638718 Share on other sites More sharing options...
lukeawade Posted September 16, 2008 Author Share Posted September 16, 2008 Any updates? I still cant get it to work Link to comment https://forums.phpfreaks.com/topic/123683-expert-needed/#findComment-642841 Share on other sites More sharing options...
lukeawade Posted October 8, 2008 Author Share Posted October 8, 2008 Still cant get it to work. Please help Link to comment https://forums.phpfreaks.com/topic/123683-expert-needed/#findComment-660001 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.