mindapolis Posted November 30, 2015 Share Posted November 30, 2015 Hi, can someone help me understand why I'm getting this error please? Fatal error: Call to undefined function display_form() in /web/html/mediaservicesunlimited.com/test/stickyForm.php on line 33 <?php ini_set('display_errors', 'On'); error_reporting(E_ALL); require_once('functions.php'); function outputErrors($sql_errors) { foreach($sql_errors as $name => $msgs) { echo('<h4 class="error">' . $name . ': ' . $msgs . '</h4>' . PHP_EOL); } } function validateInput() { global $errors; $status = true; if($_POST['fname'] == "") { $errors['fname']="Please enter your first name"; $status = false; } if($_POST['lname'] == "") { $errors['lname']="Please enter your last name"; $status = false; } return $status; } if(isset($_POST['submit'])) { ValidateInput(); if(count($errors) != 0) { display_form(); } else { display_form(); } $sql_errors = array(); $mysqli = databaseConnection(); if(!$stmt = $mysqli->prepare("INSERT INTO clients(fname, lname, orgName, address, city, state, zipcode, phone, fax, email, confirmEmail, projectOptions, projectOverview, year) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) { $sql_errors["Prepare"] = $mysqli->error . PHP_EOL; } else { if(!$stmt->bind_param('ssssssiiissisi', $_POST["fname"], $_POST["lname"], $_POST["orgName"], $_POST["address"], $_POST["city"], $_POST["state"], $_POST["zipcode"], $_POST["phone"], $_POST["fax"], $_POST["email"], $_POST["confirmEmail"], $_POST["projectOptions"], $_POST["projectOverview"], $_POST["year"])) { $sql_errors["bind_param"] = $stmt->error . PHP_EOL; } else { if(!$stmt->execute()) { $sql_errors["execute"] = $stmt->error . PHP_EOL; } $stmt->close(); } } $mysqli->close(); header('contactTest.php'); } ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Untitled Document</title> <style type="text/css"> .error { color: #FF0000; } </style> </head> <body> <?php if(isset($sql_errors) && sizeof($sql_errors) > 0) outputErrors($sql_errors);?> <form action="stickyForm.php" method="post"> <label> <input id="fname" type="text" name="fname" size="15" placeholder="First Name" value ="<?php if(isset($_POST['fname'])) echo $_POST['fname'];?>" > <input type="text" name="lname" size="20" placeholder="Last Name"><?php echo !empty($error['lname']) ? $error['lname'] : '';?> <input type="text" name="orgName" placeholder="Organization's Name"maxlength="50"> </label><br /> <label> <!--new row --> <input id="address" type="text" name="address" size="15" placeholder="Street Addresss" maxlength="50"> <input id="city" type="text" name="city" placeholder="City" size="10" maxlength="25"> <select id="state" name="state" placeholder="State" value=""> <option value ="">Please choose a state</option> <?php states($state); ?> </select> <input id = "zipcode" type="number" name="zipcode" placeholder="Zip Code" size="5" maxlength="5"> </label><br /> <label> <!--new row --> <input type="text" name="phone" placeholder="Phone Number:(including area code)" size="10" maxlength="10"> <input type="text" name="fax" size="10" placeholder="Fax Number: (including area code)" maxlength="10"> </label><br /> <label> <!--new row--> <input type="text" id = "email" name="email" placeholder="Email Address" /> <input type="text" id = "confirmEmail" name="confirmEmail" placeholder="Confirm Email Address" /> </label><br /> <label> <!--new row --> What would you like help with? <table id="projectOptions"> <tr span=2> <td><input type="checkbox" name="projectOptions[]" id="projectOptions[]" value="socialMedia">Social Media</td> <td><input type="checkbox" name="projectOptions[]" id="projectOptions[]" value="webContent">Web Content Management</td> </tr> <tr> <td><input name="projectOptions[]" type="checkbox" checked="checked" id="projectOptions[]" value="marketingMaterial">Marketing Material Creation</td> <td><input type="checkbox" name="projectOptions[]" id="projectOptions[]" value="seo">SEO (Search Engine Optimization)</td> </tr> <tr> <td><input type="checkbox" name="projectOptions[]" id="projectOptions[]" value="videoEditing"> Video Editing</td> <td><input type="checkbox" name="projectOptions[]" id="projectOptions[]" value="webDesign">Web Design</td> </tr> </table> </label> Overview about the project:<textarea rows="5" cols="10" placeholder="Overview of Project"></textarea><br /> If you are not a robot, what year is it? <input type="text" name="year" size="4" maxlength="4"><br /> <input type="submit" name="submit" value="Contact Me!"> <input type="reset" name="reset" value="Cancel"> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/299608-a-little-help-please/ Share on other sites More sharing options...
QuickOldCar Posted November 30, 2015 Share Posted November 30, 2015 Is there a display_form() included in functions.php? 1 Quote Link to comment https://forums.phpfreaks.com/topic/299608-a-little-help-please/#findComment-1527326 Share on other sites More sharing options...
gizmola Posted November 30, 2015 Share Posted November 30, 2015 ^^^^ Seems pretty clear that there isn't a display_form() function defined anywhere that this script has access to call. Quote Link to comment https://forums.phpfreaks.com/topic/299608-a-little-help-please/#findComment-1527328 Share on other sites More sharing options...
mindapolis Posted November 30, 2015 Author Share Posted November 30, 2015 No, I'm sorry, I thought display_form() was a predefined function, sorry. Quote Link to comment https://forums.phpfreaks.com/topic/299608-a-little-help-please/#findComment-1527329 Share on other sites More sharing options...
gizmola Posted November 30, 2015 Share Posted November 30, 2015 No, I'm sorry, I thought display_form() was a predefined function, sorry. No, sure isn't. Keep in mind you can always use the php.net site. It supports a rewrite for every function via http://php.net/function_name. So for example: http://php.net/date_format Worth trying when in doubt. 1 Quote Link to comment https://forums.phpfreaks.com/topic/299608-a-little-help-please/#findComment-1527331 Share on other sites More sharing options...
mindapolis Posted November 30, 2015 Author Share Posted November 30, 2015 Again, I apologize for my mistake. I corrected that mistake and now the form won't display at all. it's just a blank page. if someone could nicely point me in the right direction, I would really appreciate it. <?php ini_set('display_errors', 'On'); error_reporting(E_ALL); require_once('functions.php'); function outputErrors($sql_errors) { foreach($sql_errors as $name => $msgs) { echo('<h4 class="error">' . $name . ': ' . $msgs . '</h4>' . PHP_EOL); } } $errors=array(); //validate user's input if(isset($_POST['submit'])) { validateInput(); if(count($errors) != 0) { display_form(); } else { display_form(); } function validateInput() { global $errors; $status = true; if($_POST['fname'] == "") { $errors['fname']="Please enter your first name"; $status = false; } if($_POST['lname'] == "") { $errors['lname']="Please enter your last name"; $status = false; } return $status; } //end user validation $sql_errors = array(); $mysqli = databaseConnection(); if(!$stmt = $mysqli->prepare("INSERT INTO clients(fname, lname, orgName, address, city, state, zipcode, phone, fax, email, confirmEmail, projectOptions, projectOverview, year) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) { $sql_errors["Prepare"] = $mysqli->error . PHP_EOL; } else { if(!$stmt->bind_param('ssssssiiissisi', $_POST["fname"], $_POST["lname"], $_POST["orgName"], $_POST["address"], $_POST["city"], $_POST["state"], $_POST["zipcode"], $_POST["phone"], $_POST["fax"], $_POST["email"], $_POST["confirmEmail"], $_POST["projectOptions"], $_POST["projectOverview"], $_POST["year"])) { $sql_errors["bind_param"] = $stmt->error . PHP_EOL; } else { if(!$stmt->execute()) { $sql_errors["execute"] = $stmt->error . PHP_EOL; } $stmt->close(); } } $mysqli->close(); header('contactTest.php'); } ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Untitled Document</title> <style type="text/css"> .error { color: #FF0000; } </style> </head> <body> <?php if(isset($sql_errors) && sizeof($sql_errors) > 0) outputErrors($sql_errors); function display_form() { global $errors; ?> <form action="stickyForm.php" method="post"> <label> <input id="fname" type="text" name="fname" size="15" placeholder="First Name" value ="<?php if(isset($_POST['fname'])) echo $_POST['fname'];?>" > <input type="text" name="lname" size="20" placeholder="Last Name"><?php echo !empty($error['lname']) ? $error['lname'] : '';?> <input type="text" name="orgName" placeholder="Organization's Name"maxlength="50"> </label><br /> <label> <!--new row --> <input id="address" type="text" name="address" size="15" placeholder="Street Addresss" maxlength="50"> <input id="city" type="text" name="city" placeholder="City" size="10" maxlength="25"> <select id="state" name="state" placeholder="State" value=""> <option value ="">Please choose a state</option> <?php states($state); ?> </select> <input id = "zipcode" type="number" name="zipcode" placeholder="Zip Code" size="5" maxlength="5"> </label><br /> <label> <!--new row --> <input type="text" name="phone" placeholder="Phone Number:(including area code)" size="10" maxlength="10"> <input type="text" name="fax" size="10" placeholder="Fax Number: (including area code)" maxlength="10"> </label><br /> <label> <!--new row--> <input type="text" id = "email" name="email" placeholder="Email Address" /> <input type="text" id = "confirmEmail" name="confirmEmail" placeholder="Confirm Email Address" /> </label><br /> <label> <!--new row --> What would you like help with? <table id="projectOptions"> <tr span=2> <td><input type="checkbox" name="projectOptions[]" id="projectOptions[]" value="socialMedia">Social Media</td> <td><input type="checkbox" name="projectOptions[]" id="projectOptions[]" value="webContent">Web Content Management</td> </tr> <tr> <td><input name="projectOptions[]" type="checkbox" checked="checked" id="projectOptions[]" value="marketingMaterial">Marketing Material Creation</td> <td><input type="checkbox" name="projectOptions[]" id="projectOptions[]" value="seo">SEO (Search Engine Optimization)</td> </tr> <tr> <td><input type="checkbox" name="projectOptions[]" id="projectOptions[]" value="videoEditing"> Video Editing</td> <td><input type="checkbox" name="projectOptions[]" id="projectOptions[]" value="webDesign">Web Design</td> </tr> </table> </label> Overview about the project:<textarea rows="5" cols="10" placeholder="Overview of Project"></textarea><br /> If you are not a robot, what year is it? <input type="text" name="year" size="4" maxlength="4"><br /> <input type="submit" name="submit" value="Contact Me!"> <input type="reset" name="reset" value="Cancel"> </form> <?php } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/299608-a-little-help-please/#findComment-1527333 Share on other sites More sharing options...
gizmola Posted November 30, 2015 Share Posted November 30, 2015 First I'd suggest moving your function display_form() { .... } code to the top of the script right after your other function declaration and before your actual script logic code. Re-run ad check your error logs and see what they are telling you. Quote Link to comment https://forums.phpfreaks.com/topic/299608-a-little-help-please/#findComment-1527337 Share on other sites More sharing options...
mindapolis Posted November 30, 2015 Author Share Posted November 30, 2015 (edited) so put function display_form() { global $errors; before ?> <!doctype html> ? Edited November 30, 2015 by mindapolis Quote Link to comment https://forums.phpfreaks.com/topic/299608-a-little-help-please/#findComment-1527339 Share on other sites More sharing options...
gizmola Posted November 30, 2015 Share Posted November 30, 2015 I took your code and did the moving for you. Once you start moving things into sections, the logic issues with your current code start to become more obvious. What's obvious at present is that the html header code needs to be either separated or moved inside a function so that it can be rendered before the form code is rendered OR before the error code is rendered. <?php ini_set('display_errors', 'On'); error_reporting(E_ALL); require_once('functions.php'); function outputErrors($sql_errors) { foreach($sql_errors as $name => $msgs) { echo('<h4 class="error">' . $name . ': ' . $msgs . '</h4>' . PHP_EOL); } } function validateInput() { global $errors; $status = true; if($_POST['fname'] == "") { $errors['fname']="Please enter your first name"; $status = false; } if($_POST['lname'] == "") { $errors['lname']="Please enter your last name"; $status = false; } return $status; } //end user validation function display_form() { global $errors; ?> <form action="stickyForm.php" method="post"> <label> <input id="fname" type="text" name="fname" size="15" placeholder="First Name" value ="<?php if(isset($_POST['fname'])) echo $_POST['fname'];?>" > <input type="text" name="lname" size="20" placeholder="Last Name"><?php echo !empty($error['lname']) ? $error['lname'] : '';?> <input type="text" name="orgName" placeholder="Organization's Name"maxlength="50"> </label><br /> <label> <!--new row --> <input id="address" type="text" name="address" size="15" placeholder="Street Addresss" maxlength="50"> <input id="city" type="text" name="city" placeholder="City" size="10" maxlength="25"> <select id="state" name="state" placeholder="State" value=""> <option value ="">Please choose a state</option> <?php states($state); ?> </select> <input id = "zipcode" type="number" name="zipcode" placeholder="Zip Code" size="5" maxlength="5"> </label><br /> <label> <!--new row --> <input type="text" name="phone" placeholder="Phone Number:(including area code)" size="10" maxlength="10"> <input type="text" name="fax" size="10" placeholder="Fax Number: (including area code)" maxlength="10"> </label><br /> <label> <!--new row--> <input type="text" id = "email" name="email" placeholder="Email Address" /> <input type="text" id = "confirmEmail" name="confirmEmail" placeholder="Confirm Email Address" /> </label><br /> <label> <!--new row --> What would you like help with? <table id="projectOptions"> <tr span=2> <td><input type="checkbox" name="projectOptions[]" id="projectOptions[]" value="socialMedia">Social Media</td> <td><input type="checkbox" name="projectOptions[]" id="projectOptions[]" value="webContent">Web Content Management</td> </tr> <tr> <td><input name="projectOptions[]" type="checkbox" checked="checked" id="projectOptions[]" value="marketingMaterial">Marketing Material Creation</td> <td><input type="checkbox" name="projectOptions[]" id="projectOptions[]" value="seo">SEO (Search Engine Optimization)</td> </tr> <tr> <td><input type="checkbox" name="projectOptions[]" id="projectOptions[]" value="videoEditing"> Video Editing</td> <td><input type="checkbox" name="projectOptions[]" id="projectOptions[]" value="webDesign">Web Design</td> </tr> </table> </label> Overview about the project:<textarea rows="5" cols="10" placeholder="Overview of Project"></textarea><br /> If you are not a robot, what year is it? <input type="text" name="year" size="4" maxlength="4"><br /> <input type="submit" name="submit" value="Contact Me!"> <input type="reset" name="reset" value="Cancel"> </form> <?php } $errors=array(); //validate user's input if(isset($_POST['submit'])) { validateInput(); if(count($errors) != 0) { display_form(); } else { display_form(); } $sql_errors = array(); $mysqli = databaseConnection(); if(!$stmt = $mysqli->prepare("INSERT INTO clients(fname, lname, orgName, address, city, state, zipcode, phone, fax, email, confirmEmail, projectOptions, projectOverview, year) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) { $sql_errors["Prepare"] = $mysqli->error . PHP_EOL; } else { if(!$stmt->bind_param('ssssssiiissisi', $_POST["fname"], $_POST["lname"], $_POST["orgName"], $_POST["address"], $_POST["city"], $_POST["state"], $_POST["zipcode"], $_POST["phone"], $_POST["fax"], $_POST["email"], $_POST["confirmEmail"], $_POST["projectOptions"], $_POST["projectOverview"], $_POST["year"])) { $sql_errors["bind_param"] = $stmt->error . PHP_EOL; } else { if(!$stmt->execute()) { $sql_errors["execute"] = $stmt->error . PHP_EOL; } $stmt->close(); } } $mysqli->close(); header('contactTest.php'); } ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Untitled Document</title> <style type="text/css"> .error { color: #FF0000; } </style> </head> <body> <?php if(isset($sql_errors) && sizeof($sql_errors) > 0) outputErrors($sql_errors); ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/299608-a-little-help-please/#findComment-1527342 Share on other sites More sharing options...
mindapolis Posted November 30, 2015 Author Share Posted November 30, 2015 I uploaded your code and it dilsplays a blank page. Quote Link to comment https://forums.phpfreaks.com/topic/299608-a-little-help-please/#findComment-1527349 Share on other sites More sharing options...
mindapolis Posted November 30, 2015 Author Share Posted November 30, 2015 wait, your code can't be right can it? THe doctype is at the bottom of the page. Quote Link to comment https://forums.phpfreaks.com/topic/299608-a-little-help-please/#findComment-1527355 Share on other sites More sharing options...
gizmola Posted November 30, 2015 Share Posted November 30, 2015 Exactly. As I said above, when you move the functions around it makes it clearer that you have logic holes in what you were doing. I didn't fix your code, just ordered it so that it wasn't so confusing and you could see clearly what you had. Quote Link to comment https://forums.phpfreaks.com/topic/299608-a-little-help-please/#findComment-1527361 Share on other sites More sharing options...
mindapolis Posted November 30, 2015 Author Share Posted November 30, 2015 will you be around tonight for any questions? Quote Link to comment https://forums.phpfreaks.com/topic/299608-a-little-help-please/#findComment-1527362 Share on other sites More sharing options...
mindapolis Posted November 30, 2015 Author Share Posted November 30, 2015 Does it matter if the doctype come before or after the bulk of the PHP? Quote Link to comment https://forums.phpfreaks.com/topic/299608-a-little-help-please/#findComment-1527367 Share on other sites More sharing options...
ginerjm Posted November 30, 2015 Share Posted November 30, 2015 A good model for script design is to set your php code all up front and your html all at the end. They don't need to mix unless you are using php vars to convey html with dynamic embedded data into the final webpage output. Keeps the logic and heavy work away from the presentation and display work. No need to output intermittent dribs and drabs of html while you are trying to write the "serious" code. Quote Link to comment https://forums.phpfreaks.com/topic/299608-a-little-help-please/#findComment-1527369 Share on other sites More sharing options...
mindapolis Posted December 1, 2015 Author Share Posted December 1, 2015 I dont understand this at all. I took out all the SQL code out temporary so I could get just this part to work. I'm following an example from an old PHP book, but it is not working and I'm getting really frustrated. When i try to display the form on the webpage, all I get is a blank page. if someone could PLEASE help me, I would really appreciate it. <?php ini_set('display_errors', 'On'); error_reporting(E_ALL); require_once('functions.php'); $errors=array(); //validate user's input if(isset($_POST['submit'])) { validateInput(); if(count($errors) != 0) { display_form(); } else { display_form();} function validateInput() { global $errors; if($_POST['fname'] == "") { $errors['fname']="Please enter your first name"; } /*if($_POST['lname'] == "") { $errors['lname']="Please enter your last name"; $status = false; } return $status;*/ }} //end user validation ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Untitled Document</title> <style type="text/css"> .error { color: #FF0000; } </style> </head> <body> <?php function display_form() { global $errors; ?> <form action="stickyForm.php" method="post"> <label> <input id="fname" type="text" name="fname" size="15" placeholder="First Name" value ="<?php echo $_POST[fname];//if(isset($_POST['fname'])) echo $_POST['fname'];?>" > <input type="text" name="lname" size="20" placeholder="Last Name"><?php //echo !empty($error['lname']) ? $error['lname'] : '';?> <input type="text" name="orgName" placeholder="Organization's Name"maxlength="50"> </label><br /> <label> <!--new row --> <input id="address" type="text" name="address" size="15" placeholder="Street Addresss" maxlength="50"> <input id="city" type="text" name="city" placeholder="City" size="10" maxlength="25"> <select id="state" name="state" placeholder="State" value=""> <option value ="">Please choose a state</option> <?php states($state); ?> </select> <input id = "zipcode" type="number" name="zipcode" placeholder="Zip Code" size="5" maxlength="5"> </label><br /> <label> <!--new row --> <input type="text" name="phone" placeholder="Phone Number:(including area code)" size="10" maxlength="10"> <input type="text" name="fax" size="10" placeholder="Fax Number: (including area code)" maxlength="10"> </label><br /> <label> <!--new row--> <input type="text" id = "email" name="email" placeholder="Email Address" /> <input type="text" id = "confirmEmail" name="confirmEmail" placeholder="Confirm Email Address" /> </label><br /> <label> <!--new row --> What would you like help with? <table id="projectOptions"> <tr span=2> <td><input type="checkbox" name="projectOptions[]" id="projectOptions[]" value="socialMedia">Social Media</td> <td><input type="checkbox" name="projectOptions[]" id="projectOptions[]" value="webContent">Web Content Management</td> </tr> <tr> <td><input name="projectOptions[]" type="checkbox" checked="checked" id="projectOptions[]" value="marketingMaterial">Marketing Material Creation</td> <td><input type="checkbox" name="projectOptions[]" id="projectOptions[]" value="seo">SEO (Search Engine Optimization)</td> </tr> <tr> <td><input type="checkbox" name="projectOptions[]" id="projectOptions[]" value="videoEditing"> Video Editing</td> <td><input type="checkbox" name="projectOptions[]" id="projectOptions[]" value="webDesign">Web Design</td> </tr> </table> </label> Overview about the project:<textarea rows="5" cols="10" placeholder="Overview of Project"></textarea><br /> If you are not a robot, what year is it? <input type="text" name="year" size="4" maxlength="4"><br /> <input type="submit" name="submit" value="Contact Me!"> <input type="reset" name="reset" value="Cancel"> </form> <?php } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/299608-a-little-help-please/#findComment-1527380 Share on other sites More sharing options...
mindapolis Posted December 1, 2015 Author Share Posted December 1, 2015 I figure it out on a smaller scale! Hopefully I can transfer it on o the bigger form. Quote Link to comment https://forums.phpfreaks.com/topic/299608-a-little-help-please/#findComment-1527381 Share on other sites More sharing options...
mindapolis Posted December 1, 2015 Author Share Posted December 1, 2015 I kind of got it working. if the first name textbox is empty, but the last name is fliled in, it displays the error message but it does 't keep the last name input. I thought the whole purpose of sticky forms is to keep the form data intact while showing what information is still needed. <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <?php $problem = false; if(isset($_POST['submit'])) { if(empty($_POST['fname'])) { $problem = true; echo "Please enter your first name"; } } ?> <form action="sticky2.php" method="post"> <label> <input id="fname" type="text" name="fname" size="15" placeholder="First Name" value ="<?php echo $_POST[fname];//if(isset($_POST['fname'])) echo $_POST['fname'];?>" > <input type="text" name="lname" size="20" placeholder="Last Name"><?php //echo !empty($error['lname']) ? $error['lname'] : '';?> </label> <input type="submit" name="submit" value="Contact Me!"> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/299608-a-little-help-please/#findComment-1527382 Share on other sites More sharing options...
benanamen Posted December 1, 2015 Share Posted December 1, 2015 (edited) Dont use if(isset($_POST['submit']) There are issues with it in Internet Explorer. You can do your own research as to what the issues are. Edited December 1, 2015 by benanamen Quote Link to comment https://forums.phpfreaks.com/topic/299608-a-little-help-please/#findComment-1527385 Share on other sites More sharing options...
mindapolis Posted December 1, 2015 Author Share Posted December 1, 2015 Look, I have been dealing this issue for several days and I have done A LOT of research! If someone could be nicer and help me with this I would really appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/299608-a-little-help-please/#findComment-1527392 Share on other sites More sharing options...
cyberRobot Posted December 1, 2015 Share Posted December 1, 2015 I kind of got it working. if the first name textbox is empty, but the last name is fliled in, it displays the error message but it does 't keep the last name input. I thought the whole purpose of sticky forms is to keep the form data intact while showing what information is still needed. The code for re-populating the last name field is commented out. Try using something like the following: <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <?php $problem = false; if($_SERVER['REQUEST_METHOD'] == 'POST') { if(empty($_POST['fname'])) { $problem = true; echo "Please enter your first name"; } } ?> <form action="sticky2.php" method="post"> <input type="text" name="fname" size="15" placeholder="First Name" value="<?php if(isset($_POST['fname'])) { echo $_POST['fname']; } ?>"> <input type="text" name="lname" size="20" placeholder="Last Name" value="<?php if(isset($_POST['lname'])) { echo $_POST['lname']; } ?>"> <input type="submit" name="submit" value="Contact Me!"> </form> </body> </html> Note that I removed the <label> tag since you weren't really using it. To be honest, I'm not sure if the <label> tag is needed when you're using the "placeholder" attribute. Perhaps that's something else to research. I also removed the "id" attribute from the first name field since it probably isn't being used. Quote Link to comment https://forums.phpfreaks.com/topic/299608-a-little-help-please/#findComment-1527395 Share on other sites More sharing options...
mindapolis Posted December 1, 2015 Author Share Posted December 1, 2015 I think I'm getting it Quote Link to comment https://forums.phpfreaks.com/topic/299608-a-little-help-please/#findComment-1527417 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.