so its a basic page of html and php . and in was working fine until i change action="details.php" before it was action="signup.php" (this was the name of the page itself)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>login page</title>
<style>
form {
display: block;
}
body{
align-items: center;
}
</style>
</head>
<body>
<form action="details.php" method="post" style="text-align: center;">
<img src="https://media.giphy.com/media/JQdcW7EHWqxWxrS3B6/giphy.gif" alt="logo" width=15% height=15%>
<h1 >Signup to TRACK your Orders</h1>
<?php
$flag = false;
if(isset($_POST['fname'])==true){
$server = "localhost";
$user = "root";
$pass = "";
$db="choclate";
$c = mysqli_connect($server, $user, $pass,$db);
if(!$c)
echo "Error";
$q="CREATE TABLE `signup`
( `fname` VARCHAR(10) NOT NULL ,
`lname` VARCHAR(10) NOT NULL ,
`email` VARCHAR(50) NOT NULL ,
`pass` VARCHAR(50) NOT NULL );";
$er=mysqli_query($c,$q);
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$pass = $_POST['pass'];
$sql="INSERT INTO `signup` (`fname`, `lname`, `email`, `pass`) VALUES ('$fname', '$lname', '$email', '$pass');";
if(($c->query($sql))==true){
$flag=true;
}?>
<input name="fname" id="fname" type="text" placeholder="First Name" required autofocus><br><br>
<input name="lname" id="lname" type="text" placeholder="Last Name" required ><br><br>
<input name="email" id="email" type="email" placeholder="Email address" required><br><br>
<input name="pass" id="pass" type="text" placeholder="Password" required><br><br>
<button >Signup</button>
<p >© The Creative Touch</p>
</form>
</body>
</html>
i have to submit it by tomorrow i have work very hard to make this project so please help me thanks in advance
CodePudding user response:
you are changing its action to somewhere else so it wont the code wont get executed if you want to execute the code in signup.php then use this php code in signup.php
CodePudding user response:
Make the action empty like below action=""
But if you want to redirect to after insertion then you can put below inside 2nd if statement:
header("Location: details.php"); exit();
OR
create the details.php file in the same folder/directory as signup.php and put your php code inside if you want to maintain the action="details.php"