Jump to content

Keeping data in form


distant

Recommended Posts

Thanks for replying mraza

I mean keeping an username and password on the field of the form once I click submit. Hope that's clear.

 

what do you mean by keep?

you wants to store in database?

you wants to send email of that form?

or anything else?

 

please explain

Link to comment
https://forums.phpfreaks.com/topic/182644-keeping-data-in-form/#findComment-963976
Share on other sites

this is what I got and I want the username and pass to stay in the flield once i submit it.

 

 

 

$message = "<p>Please enter your login information below:</p>" ;

$tempUsername = ($_POST["username"]) ;

$tempPass = ($_POST["password"]) ;

$congrats = "<span class='stylesheet'><p>Congrats, you successfully logged in.<p/></span>" ;

$sorry = "<span class='style1'><p>Sorry, your username and password combo was not correct, please try again.</p></span>" ;

 

 

if (isset($_POST ['submit']))

{

if($tempUsername == "Michael")

{

echo $congrats ;

}

elseif($tempPass == "pass")

{

echo $Congrats ;

}

else echo $sorry ;

}

else echo $message ;

 

 

 

 

<form id="form1" name="form1" method="post" action="login.php">

  <p>

      <label for="username">Username:</label><br />

      <input type="text" name="username" id="username" value="" />

  </p>

  <p>

      <label for="password">Password:</label><br />

      <input type="text" name="password" id="password" value="" />

  </p>

  <p><input name="submit" type="submit" /></p>

</form>

Link to comment
https://forums.phpfreaks.com/topic/182644-keeping-data-in-form/#findComment-963987
Share on other sites

Well like we said: add the value attributes to your input tags like this:

<form id="form1" name="form1" method="post" action="login.php">
  <p>
      <label for="username">Username:</label><br />
      <input type="text" name="username" id="username" value="<?php echo $tempUsername?>" />
  </p>
  <p>
      <label for="password">Password:</label><br />
      <input type="text" name="password" id="password" value="<?php echo $tempPass?>" />
  </p>
  <p><input name="submit" type="submit" /></p>
</form>

Link to comment
https://forums.phpfreaks.com/topic/182644-keeping-data-in-form/#findComment-963997
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.