🔒 Closed Gusto ko madagdagan ng lastname age confirm password yung output

Status
Not open for further replies.

Raimeesky

Fanatic
<!doctype html>
<html>
<head>
<title>Register</title>
</head>
<body>

<p><a href="register.php">Register</a> | <a href="login.php">Login</a></p>
<h3>Registration Form</h3>
<form action="" method="POST">
Username: <input type="text" name="user"><br />
Password: <input type="password" name="pass"><br />
<input type="submit" value="Register" name="submit" />
</form>
<?php
if(isset($_POST["submit"])){

if(!empty($_POST['user']) && !empty($_POST['pass'])) {
$user=$_POST['user'];
$pass=$_POST['pass'];

$con=mysql_connect('localhost','root','') or die(mysql_error());
mysql_select_db('user_registration') or die("cannot select DB");

$query=mysql_query("SELECT * FROM login WHERE username='".$user."'");
$numrows=mysql_num_rows($query);
if($numrows==0)
{
$sql="INSERT INTO login(username,password) VALUES('$user','$pass')";

$result=mysql_query($sql);


if($result){
echo "Account Successfully Created";
} else {
echo "Failure!";
}

} else {
echo "That username already exists! Please try again with another.";
}

} else {
echo "All fields are required!";
}
}
?>

</body>
</html>
 
<!doctype html>
<html>
<head>
<title>Register</title>
</head>
<body>

<p><a href="register.php">Register</a> | <a href="login.php">Login</a></p>
<h3>Registration Form</h3>
<form action="" method="POST">
Lastname: <input type="text" name="lname"> <br/>
Age: <input type="text" name="age"> <br /> // Pwede din type="number", depende sayo.
Username: <input type="text" name="user"><br />
Password: <input type="password" name="pass"><br />
Confirm Password: <input type="password" name="cpass"> <br />
<input type="submit" value="Register" name="submit" />
</form>

<?php
if(isset($_POST["submit"])){

if(!empty($_POST['user']) && !empty($_POST['pass']) && !empty($_POST['lname']) && !empty($_POST['age']) && !empty($_POST['cpass']) {
$user=$_POST['user'];
$pass=$_POST['pass'];
$lname = $_POST['lname'];
$age = $_POST['age'];
$cpass = $_POST['cpass'];

if ($pass == $cpass) {

$con=mysql_connect('localhost','root','') or die(mysql_error());
mysql_select_db('user_registration') or die("cannot select DB");

$query=mysql_query("SELECT * FROM login WHERE username='".$user."'");
$numrows=mysql_num_rows($query);

if($numrows==0) {
$sql="INSERT INTO login(lastname,age,username,password) VALUES('$lname','$age','$user','$pass')";

$result=mysql_query($sql);

if($result){
echo "Account Successfully Created";
} else {
echo "Failure!";
}

} else {
echo "That username already exists! Please try again with another.";
}
} else {
echo "Password don't match.
}

} else {
echo "All fields are required!";
}
}
?>

</body>
</html>




Edited your codes. Let me know kung may na mistype ako hahahaha. Tip lang, practice "clean coding", ikaw din mahihirapan pag ganyan.
 
Status
Not open for further replies.

About this Thread

  • 3
    Replies
  • 776
    Views
  • 3
    Participants
Last reply from:
Mrkmrk

Trending Topics

Online now

Members online
1,122
Guests online
3,926
Total visitors
5,048

Forum statistics

Threads
2,306,427
Posts
29,171,624
Members
1,194,814
Latest member
jasperboy123456
Back
Top