tmharrison Posted February 10, 2007 Share Posted February 10, 2007 Input is done on an html page, then php script checks for valid info, but when errors are found, it lists them on another blank page? can i get the errors to be on the html page? thanks tina Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 10, 2007 Share Posted February 10, 2007 Make the HTML page a PHP page and then yes, you can. You can either proccess the form on the same page, or store the errors in the session and send them back. Quote Link to comment Share on other sites More sharing options...
mattd8752 Posted February 10, 2007 Share Posted February 10, 2007 echo the errors and <br> then include "thehtmlpage.html"; Quote Link to comment Share on other sites More sharing options...
tmharrison Posted February 10, 2007 Author Share Posted February 10, 2007 Thank you, jesirose and mattd8752 jesirose, i didn't understand the sessions, part, so I went with mattd8752's reply. i can get it to work mattd8752, thank you very much. is there a way to embed it into a specific spot on my html page? thank you so much tina Quote Link to comment Share on other sites More sharing options...
tmharrison Posted February 10, 2007 Author Share Posted February 10, 2007 Jesirose Can you please explain your process to me. I understand the saving as php page, I need to understand, what you mean by processing the form on the same page and then the sessions part. As i can' t seem to get the errors to list inside the html page by using the include statement. Thank you, Tina Quote Link to comment Share on other sites More sharing options...
.josh Posted February 10, 2007 Share Posted February 10, 2007 very simple example: form.php <?php session_start(); if($_SESSION['errorMsg']) { echo $_SESSION['errorMsg']; unset ($_SESSION['errorMsg']); } ?> <form method = 'post' action='process.php'> Enter something <input type = 'text' name = 'something'> <input type = 'submit' value = 'send'> </form> process.php <?php session_start(); if (!isset($_POST['something']) || trim($_POST['something']) == "") { $_SESSION['errorMsg'] = "please fill out field"; } elseif (strlen($_POST['something']) > 10)) { $_SESSION['errorMsg'] = "something is too long. Please make it 10 or less chars"; } if ($_SESSION['errorMsg']) { header('Location: form.php'); exit(); } else { // no errors, do whatever. } ?> Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 10, 2007 Share Posted February 10, 2007 Good example Crayon - is that one in the FAQ/code library? Quote Link to comment Share on other sites More sharing options...
.josh Posted February 11, 2007 Share Posted February 11, 2007 umm...it might be similar. I just typed it out on the spot. Quote Link to comment Share on other sites More sharing options...
tmharrison Posted February 11, 2007 Author Share Posted February 11, 2007 Still a little bit unclear to me, probably because of never using sessions before. below is what and how I am dealing with errors on the "process side of things, which is my register.php" if(isset($_POST['Send'])){ $errors = array(); // Initialize error array. if(empty($_POST['name'])) { $errors[] = 'You did not enter your Name.'; below is the scaled down version of my registration.php form which is really just html <form action="register.php" method="post" target="_self"> <tr> <td height="20" colspan="3" align="left" valign="top"><input name="name" type="text" class="graytext1" id="name" size="60"> <td height="20" align="left" valign="top"><input name="email" type="text" class="graytext1" id="email"> <tr> <td height="15" colspan="2" align="left" valign="bottom" class="graytext">Address <td height="15" colspan="2" align="left" valign="bottom" class="graytext">Add'l Address <tr> <td height="20" colspan="2" align="left" valign="top"><input name="address" type="text" class="graytext1" id="address" size="40"> this is the bottom of my register.php for the errors } else { echo '<id="errors">Error!<p class="error">The following error(s) occurred:<br />'; foreach ($errors as $msg) { echo " - $msg<br />\n"; if you could possibly let me know where things should go, that would probably make it clearer to me. Thank you, Tina 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.