mattrd Posted February 10, 2009 Share Posted February 10, 2009 I want to make my email input and password input sticky so if they fill out email but don't fill out password they don't both reset. I would assume that I should put the input value as value=\"if (isset($_POST['email'])) echo $_POST['email'];\" but this isn't working and I am getting an error what am I doing wrong? If anyone could help me I'd really appreciate it. thank you! here is all my code (without the values in the inputs) <div id="right_nav"> <div id="tip">Welcome to the Berks County Foster Parent Association Website</div> <div id="login"> <?php /* write a conditional to see if form was submitted */ if (isset($_POST['submitted'])) { if (!empty($_POST['email']) && !empty($_POST['password'])) { echo "<p class=\"center bold\">Welcome User!<br />\n You are currently logged in.</p><p class=\"center\">\n\n <a href=\"#\" style=\"left:0\">Logout</a></p></div>"; include("user_nav.php"); } else { echo "<ul>"; if (!empty($_POST['email'])) { $email = $_POST['email']; } else { $email = NULL; echo "<li>You didn't enter an email address!</li>"; } if (!empty($_POST['password'])) { $password = $_POST['password']; } else { $password = NULL; echo "<li>You didn't enter a password!</li>"; } echo "</ul>"; echo "<form action=\"index.php\" method=\"post\"> <p><span>Email Address:</span><br /><input class=\"login_input\" type=\"text\" name=\"email\" /></p> <p><span>Password:</span><br /><input class=\"login_input\" type=\"password\" name=\"password\" /></p> <p><input id=\"login_button\" type=\"submit\" name=\"submit\" value=\"Login\" /><a href=\"#\">forgot password</a></p> <input type=\"hidden\" name=\"submitted\" value=\"TRUE\" /> </form></div>"; include("general_nav.php"); } } else { echo "<form action=\"index.php\" method=\"post\"> <p><span>Email Address:</span><br /><input class=\"login_input\" type=\"text\" name=\"email\" /></p> <p><span>Password:</span><br /><input class=\"login_input\" type=\"password\" name=\"password\" /></p> <p><input id=\"login_button\" type=\"submit\" name=\"submit\" value=\"Login\" /><a href=\"#\">forgot password</a></p> <input type=\"hidden\" name=\"submitted\" value=\"TRUE\" /> </form></div>"; include("general_nav.php"); } ?> </div> Quote Link to comment Share on other sites More sharing options...
Presto-X Posted February 10, 2009 Share Posted February 10, 2009 I would add something like this just befor your echo: if (!empty($_POST['email'])){$email = $_POST['email'];} if (!empty($_POST['password'])){$password = $_POST['password'];} So your code would look like this: <div id="right_nav"> <div id="tip">Welcome to the Berks County Foster Parent Association Website</div> <div id="login"> <?php /* write a conditional to see if form was submitted */ if (isset($_POST['submitted'])) { if (!empty($_POST['email']) && !empty($_POST['password'])) { echo "<p class=\"center bold\">Welcome User!<br />\n You are currently logged in.</p><p class=\"center\">\n\n <a href=\"#\" style=\"left:0\">Logout</a></p></div>"; include("user_nav.php"); } else { echo "<ul>"; if (!empty($_POST['email'])) { $email = $_POST['email']; } else { $email = NULL; echo "<li>You didn't enter an email address!</li>"; } if (!empty($_POST['password'])) { $password = $_POST['password']; } else { $password = NULL; echo "<li>You didn't enter a password!</li>"; } echo "</ul>"; if (!empty($_POST['email'])){$email = $_POST['email'];} if (!empty($_POST['password'])){$password = $_POST['password'];} echo "<form action=\"test.php\" method=\"post\"> <p><span>Email Address:</span><br /><input class=\"login_input\" type=\"text\" name=\"email\" value=\"$email\" /></p> <p><span>Password:</span><br /><input class=\"login_input\" type=\"password\" name=\"password\" value=\"$password\" /></p> <p><input id=\"login_button\" type=\"submit\" name=\"submit\" value=\"Login\" /><a href=\"#\">forgot password</a></p> <input type=\"hidden\" name=\"submitted\" value=\"TRUE\" /> </form></div>"; include("general_nav.php"); } } else { echo "<form action=\"index.php\" method=\"post\"> <p><span>Email Address:</span><br /><input class=\"login_input\" type=\"text\" name=\"email\" /></p> <p><span>Password:</span><br /><input class=\"login_input\" type=\"password\" name=\"password\" /></p> <p><input id=\"login_button\" type=\"submit\" name=\"submit\" value=\"Login\" /><a href=\"#\">forgot password</a></p> <input type=\"hidden\" name=\"submitted\" value=\"TRUE\" /> </form></div>"; include("general_nav.php"); } ?> </div> Quote Link to comment Share on other sites More sharing options...
mattrd Posted February 10, 2009 Author Share Posted February 10, 2009 thanks for the suggestions, but it doesn't seem to be working. ??? Quote Link to comment Share on other sites More sharing options...
mattrd Posted February 10, 2009 Author Share Posted February 10, 2009 neverming. I was stupid and didn't put the variable into the value attribute. thanks so much for the help!! 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.