🔒 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
  • 765
    Views
  • 3
    Participants
Last reply from:
Mrkmrk

Trending Topics

Online now

Members online
1,103
Guests online
988
Total visitors
2,091

Forum statistics

Threads
2,274,722
Posts
28,957,832
Members
1,233,408
Latest member
0226Mjane
Back
Top