Jump to content

Error in submitting form


Shahzaib

Recommended Posts

The form file is not redirctng to process2.php file after clickng sign in also when i manually open process2.php file then errors comes like this"undefined user index username and password"............

 

 

 

 

 

MAIN FILE (FORM FILE):

 

 

<form action="process2.php" method="post">

<div class="input-controls">
<input type="text" name="username" placeholder="username">
<span id="person"></span>
<div id="clear"></div>
</div>
<div class="input-controls">
<input type="password" name="password" placeholder="password">
<span id="key"></span>
<div id="clear"></div>
</div>
<div class="input-controls">
<button type="button" id="login-btn" name="signin"> sign in </button>
</div>
<div id="form-footer">
<a href="#" id="forgot">Forgot Password?</a>
<a href="#" id="create">Create an account</a>
</div>
</form>
 
PROCESS2.PHP FILE
 
<?php
 
$user = $_POST['username'];
$pass = $_POST['password'];
 
 
if($user!=" " && $pass!=" ")
{
if(isset($_POST['signin']))
{
setcookie($name,$user,time()+3600);
echo "Cookie is set";
}
}
else
{
header('location:form.php');
}
 
?>
 
I Really Appreciate your replies.thanks in advance
Link to comment
Share on other sites

The form file is not redirctng to process2.php file ...

 

 

header('location:form.php');

 

the form is probably submitting to process2.php, but process2.php is redirecting back to form.php

 

if($user!=" " && $pass!=" ")

 

 

^^^ why are you testing if those two values are not equal to a string consisting of a space " "? wouldn't you want to test each if those values are not an empty string "" and then produce a separate message for each one that is empty?

Edited by mac_gyver
Link to comment
Share on other sites

  • 4 weeks later...
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.