Reputation: 31
I am developing Login system in php.I have one file for sign up named as signup1.php
when I put details in sign up form and click on sign up button
it show same file signup1.php
with blank screen.
I want to redirect myprofile.php
when signup the user.
I put this code.
$user->redirect('myprofile.php');
code from the comment:
<?php
require_once 'dbconfig.php';
if($user->is_loggedin()!="") {
$user->redirect('myprofile.php');
}
if(isset($_POST['btn-signup'])) {
else{
try {
$stmt = $DB_con->prepare("SELECT name,email FROM customer WHERE email=:umail");
$stmt->execute(array(':umail'=>$umail));
$row=$stmt->fetch(PDO::FETCH_ASSOC);
if($row['email']==$umail) {
$error[] = "sorry email id already taken !";
} else {
if($user->register($fname,$lname,$uname,$umail,$uphone,$upass)) {
$user->redirect('myprofile.php');
}
}
} catch(PDOException $e) {
echo $e->getMessage();
}
}
}
?>
Redirect function:
class User {
public function redirect($url) {
header("Location: $url");
}
}
Upvotes: 0
Views: 99
Reputation: 17797
From the little information you provide I can see one problem. This:
if(isset($_POST['btn-signup'])) {
else{
}
}
Is not going to work, it will throw this error:
PHP Parse error: syntax error, unexpected 'else' (T_ELSE)
An if clause works like this:
if( $condition ) {
// do something if $condition is TRUE
}
else{
// do something else if $condition is FALSE
}
If I understood your code correctly you should just remove the else {
line along with its corresponding closing bracket.
Common note: If you encounter the white screen of death in PHP, without any error message, error reporting is usually disabled (wich is normal in production environments). You can activate it with these lines:
ini_set('display_errors',true);
error_reporting(E_ALL);
Alternatively you can look at the error log of your web server (if your hoster provides one, not all do).
Upvotes: 1