What's new

Closed Gusto ko madagdagan ng lastname age confirm password yung output

Status
Not open for further replies.

Raimeesky

Honorary Poster
Joined
Jul 8, 2015
Posts
235
Reaction
42
Points
135
Age
31
<!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.

Similar threads

Back
Top