Problems using a simple sign up forum in pdo

So on my Webhosting i pay $8 p.m to use older php versions and get protection and stuff until i update my files and I’m starting to update them now, i have a simple test forum below but when i enter the username and password it does not insert it to sql, ( i removed full name and pin as i have not added them to the sql yet )

I don’t understand what is wrong with the code, or is it because i am using php 5.6?


<?php
include "connect.php";
session_start();

try{
$dbh = new PDO ("mysql:host=;dbname=","","");
if(isset($_POST['signup'])){
 $name = $_POST['username'];
 $email = $_POST['email'];
 $pass = $_POST['password'];
 $date = $_POST['date'];
 $month = $_POST['month'];
 $year = $_POST['year'];
 
 $insert = $dbh->prepare("INSERT INTO users (username,email,password,date,month,year) values (:username,:email,:password,:date,:month,:year)");
$insert->bindParam(':username',$name);
$insert->bindParam(':email',$email);
$insert->bindParam(':password',$pass);
$insert->bindParam(':date',$date);
$insert->bindParam(':month',$month);
$insert->bindParam(':year',$year); 
$insert->execute();
}elseif(isset($_POST['signin'])){
 $email = $_POST['email'];
 $pass = $_POST['password'];
 
 $select = $dbh->prepare("SELECT * FROM users WHERE email='$email' and password='$pass'");
 $select->setFetchMode(PDO::FETCH_ASSOC);
 $select->execute();
 $data=$select->fetch();
 if($data['email']!=$email and $data['password']!=$pass)
 {
  echo "invalid email or pass";
 }
 elseif($data['email']==$email and $data['password']==$pass)
 {
 $_SESSION['email']=$data['email'];
    $_SESSION['username']=$data['username'];
header("location:logincheck.php"); 
 }
 }
}
catch(PDOException $e)
{
echo "error".$e->getMessage();
}

?>










<meta name="viewport" content="width=device-width, initial-scale=0.7, maximum-scale=1.0, user-scalable=yes" />
<html>
<head>

-----------------------------------------------------





<div style="width:500px ; height:600px; float:left;">
<div style="padding:85px;">
<h1>Create Account Here</h1>
<form method="post">
<input type="text" name="username" placeholder="User Name"><br><br>
<input type="text" name="email" placeholder="[email protected]"><br><br>
<input type="text" name="password" placeholder="**********"><br><br>
<select name="date">
<option value="DATE">DATE</option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
</select>
<select name="month">
<option value="MONTH">MONTH</option>
<option value="JAN">JAN</option>
<option value="FEB">FEB</option>
<option value="MAR">MAR</option>
</select>
<select name="year">
<option value="YEAR">YEAR</option>
<option value="2016">2016</option>
<option value="2015">2015</option>
<option value="2014">2014</option>
</select><br><br>
<input type="submit" name="signup" value="SIGN UP">
</form>
</div>
</div>
<div style="width:500px ; float:right; height:600px;">
<div style="padding:85px;padding-right:200px;">

<h1>Log In Here</h1>
<form method="post">
<input type="text" name="email" placeholder="[email protected]"><br><br>
<input type="text" name="password" placeholder="**********"><br><br>
<input type="submit" name="signin" value="SIGN IN">
</div>
</div>

Did you do all the things that someone took the time to write out in replies in your previous thread about a registration script, such as setting php’s error related settings so that php would help you and setting the PDO error mode to exceptions so that any database statement errors would actually throw an exception?

If your code is not inserting a row, what did occur when you submitted the form? Did you get the Registration successful message displayed on the web page?

Hi, yes i tried yours actually :smiley: , the problem was it got a white page when i uploaded, i had a good read of it and tried to check for any errors and adjusted things ofcourse but everything i did just did not work :blush

Is this the error code i should be using ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);:

And when i register with this new one it refreshes the page

www.themafiadons.com/registerkurt.php

Sponsor our Newsletter | Privacy Policy | Terms of Service