Jump to content

[SOLVED] help with a simple form


CyberShot

Recommended Posts

I have a simple form

 

<label for="username" name="username">Username or email</label>
        <input id="username" name="username" value="" title="username" class="required" tabindex="4" type="text">
        </p>
        <p>
          <label for="password" name="password">Password</label>
          <input id="password" name="password" value="" title="password" class="required" tabindex="5" type="password">
        </p>
        <p class="clear"></p>
        <a href="change_password.php" class="forgot" id="resend_password_link">Forgot your password?</a>
        <p class="remember">
          <input id="submit" value="Sign in" tabindex="6" name="submit" type="submit">
          <input id="cancel_submit" value="Cancel" tabindex="7" type="button">
[/code

the action is set for includes/handle_form.php and in the handle form, I am just trying to test that I can get the username and password and then echo out the results. Am I doing it wrong?

[code]
if(isset($_POST['submit'])){
$name = $_POST['username'];
$pass = $_POST['password'];

echo "$name ."". $pass";
}

Link to comment
https://forums.phpfreaks.com/topic/178091-solved-help-with-a-simple-form/
Share on other sites

i dont see any form tags. you have to wrap input and other form tags with <form></form> tags, like so

<form method="post" >
<label for="username" name="username">Username or email</label>
        <input id="username" name="username" value="" title="username" class="required" tabindex="4" type="text">
        </p>
        <p>
          <label for="password" name="password">Password</label>
          <input id="password" name="password" value="" title="password" class="required" tabindex="5" type="password">
        </p>
        <p class="clear"></p>
        <a href="change_password.php" class="forgot" id="resend_password_link">Forgot your password?</a>
        <p class="remember">
          <input id="submit" value="Sign in" tabindex="6" name="submit" type="submit">
          <input id="cancel_submit" value="Cancel" tabindex="7" type="button">
</form>

<fieldset id="signin_menu">
      <span class="message">Please verify your account before continue</span>
      <form method="post" id="signin" action="handle_form.php">
        <label for="username" name="username">Username or email</label>
        <input id="username" name="username" value="" title="username" class="required" tabindex="4" type="text">
        </p>
        <p>
          <label for="password" name="password">Password</label>
          <input id="password" name="password" value="" title="password" class="required" tabindex="5" type="password">
        </p>
        <p class="clear"></p>
        <a href="change_password.php" class="forgot" id="resend_password_link">Forgot your password?</a>
        <p class="remember">
          <input id="submit" value="Sign in" tabindex="6" name="submit" type="submit">
          <input id="cancel_submit" value="Cancel" tabindex="7" type="button">
        </p>
      </form>
      </fieldset>

 

that is all the code. I have the doctype in the header.php with an include in the top of the index. with the form. then the footer.php included also. I have the php code for the form in the handle_form.php

 

a simple test was all I was trying to do to make sure it was working. Then I was going to try to learn how to do the rest of the validation as the days go on.

I packaged up the whole thing. You can download it here

 

http://www.photobyiris.com/login.zip

 

I stripped out all the javascript and the code started working. as it is, the php don't work, but If I remove everything but the form code, the php starts working. Thanks for your help.

well, I deleted that bit of code becuase it doesn't really need to be there. The submit buttons works now but I still can not get anything out of the php code. I tried just a simple one

 

<?php 

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


header('location: newpage.php');

}
?>

 

it just throws a # sign onto the end of the address

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.