hi Good Morning FRIENDS…
Can anyone tell how to create login and signup page with database using AJAX in php…
Hi,
This question is too general.
There are lots of tutorials on how to use AJAX with PHP. You can easily google it.
It would be waste of time trying to write yet another one here.
But we’ll try to help if you tell what have you already tried and what problem have you encountered.
I’ve done login page , i dont no how to create SIGNUP page…
So what is the exact problem?
Basically, there is not a big difference between login and signup pages.
Both of them is just forms where user types some data and then you do something with that data.
The only difference is that with login data you’re reading from database (searching for the user), but with signup data you’re storing it into the database (creating new user).
Yes
Its not storing in database…
Can anyone tell anything wrong in this code…
Plzzzz tell me…
<?php
require_once 'dbconfig.php';
if ($_POST) {
$shopname = $_POST['shopname'];
$ownername = $_POST['ownername'];
$mobileno = $_POST['mobileno'];
$address = $_POST('address');
try {
$stmt = $db_con->prepare("INSERT INTO tbl_users1(shopname,ownername,mobileno,address) VALUES(:shopname, :ownername, :mobileno, :address)");
$stmt->bindParam(":shopname", $shopname);
$stmt->bindParam(":ownername", $ownername);
$stmt->bindParam(":mobileno", $mobileno);
$stmt->bindParam(":address", $address);
if ($stmt->execute()) {
echo "registered";
} else {
echo "Query could not execute !";
}
} catch (PDOException $e) {
echo $e->getMessage();
}
}
?>
$_POST
is always defined. and it’s not a function.
This should be $address = $_POST['address']
as @Dormilich mentioned. And if ($_POST)
will always return true. Try something like if (isset($_POST['shopname']))
if shopname is a required field to see if the values have been posted. (I am quite happy to accept a better suggestion from a php expert).
If you’re checking for whether a form has been submitted then the recommended check is
if ( $_SERVER['REQUEST_METHOD'] == 'POST' )
Thank u all
@WebMachine Just a small comment (a bit offtopic)
This is not true, $_POST is empty if you do not send a request and if ($_POST) can return false.
As @Dormilich said, it’s defined. This does not mean it is not empty.
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.