Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.