Hello Guys,
I have gave it all I got and need help in setting up a registration page then a user login page
First, Here's some of the html code I use for My Form for the Registration Page :
<form name="signup" action="http://mydomain.com/test/register/signup.php" method="post">
<input type="text" name="username" size="24" value="">
<input type="text" name="firstname" size="9">
<input type="text" name="lastname" size="9">
<input type="password" name="password" size="24">
<textarea name="streetaddress" cols="40" rows="4"></textarea>
<input type="image" src="../images/signupbutton.gif"></div></td></tr></table>
</form>
PHP CODE FOR Registration Page which I called signup.php:
<?php
if (isset($POST['signup']))
{
$username = $POST['username'];
$password = $POST['password'];
$firstname = $POST['firstname'];
$lastname = $POST['lastname'];
$streetaddress = $POST['streetaddress'];
$db = mysql_connect("localhost", "root", "password");
mysql_select_db("PAY",$db);
$result=mysql_query("INSERT INTO userinfo (username,password,first,last,streetaddress) VALUES
($username,md5($password),$first,$last,$streetaddress)") or die("Invalid query: " .
mysql_error());
}
?>
******* USER LOGIN HTML CODE
<form action="http://mydomain.com/test/users/login.php" method="post" name="login">
<input type="text" name="username" size="18" maxlength="100" border="0">
<input type="password" name="password" size="18" maxlength="100" border="0">
<input type="submit" name="Login" value="Login" border="0">
</form>
*********USER LOGIN PHP CODE -Want to Validate Username and Password then Pass to Another Page
<?php
$username = $POST['username'];
$password = $POST['password'];
//connect to the DB
$db = mysql_connect("localhost", "root", "password");
mysql_select_db("PAY",$db);
//set up the query
$query = "SELECT * FROM userinfo WHERE username = '" . $username . "' AND password = '" .
$password . "'";
//run the query and get the number of affected rows
$result = mysql_query($query, $db) or die('error making query');
if(!$row = mysql_fetch_assoc($result)){
echo 'Sorry the username and or password is not valid';
} else {
header("location: index.html");
}
?>
Summary:
Registration Page
I would like to have a user go to my registration page then fill the form out then once they press sign up I would like to insert their information into the mysql database
What Happened When I tried code above:
I did not see anything in the database but one time I got lucky and did something but all I seen was the password not as it was type but encrypted
Login Page
I would like the user who has already filled out the registration page to be authenticated and passed on to another page
What Happened When I tried code above:
Because I can't INSERT into userinfo table in the mysql database it keeps returning an error Sorry the username and or password is not valid
Please help, I chopped up the html portion a bit so this post will be more easier to read. As I am new so if you feel I need to post more in order to get help please let me know
Somebody Please help, it will be greatly appreciated
Thanks