1

I'm having trouble with data not saving to a table, I've got the following code in a file called Register.php, I have enabled error_reporting to see any errors, but none are showing. My database is called Registration and the table is called users and is being hosted on GoDaddy

<?php
require 'Connections/Connections.php';
?>

<?php
if(isset($_Post['Register'])) {

    session_start();
    $FName = $_POST['First_Name'];
    $LName = $_POST['Last_Name'];
    $Username = $_POST['Username'];
    $Email = $_POST['Email'];
    $PW = $_POST['Password'];

    $sql = $con->query("INSERT INTO users (Fname, Lname, Username, Email, Password)Values('{$Fname}', '{$LName}', '{$Username}', '{$Email}', '{$PW}')");

}
?>

<!doctype html>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<link href="Style/Master.css" rel="stylesheet" type="text/css" />
<title>Register</title>
</head>
<body>
<form action="" method="post" name="RegisterForm" id="RegisterForm">

    <div class="FormElement">
        <input name="First_Name" type="text" required="required"    class="TField" id="First_Name" placeholder="First Name">
    </div>

    <div class="FormElement">
        <input name="Last_Name" type="text" required="required" class="TField" id="Last_Name" placeholder="Last Name">
    </div>

    <div class="FormElement">
        <input name="Username" type="text" required="required" class="TField" id="Username" placeholder="Username">
    </div>

    <div class="FormElement">
        <input name="Email" type="text" required="required" class="TField"   id="Email" placeholder="Email">
    </div>

    <div class="FormElement">
        <input name="Password" type="text" required="required" class="TField" id="Password" placeholder="Password">
    </div>

    <div class="FormElement">
        <input name="Register" type="submit" class="button" id="Register"        placeholder="Register">
    </div>
</body>
</html>

This is the code in the Connections.php just without my real username and password

<?php

$con = mysql_connect("localhost", "USERNAME", "PASSWORD", "Registration");

?>

Any help would be very much appreciated!

7
  • update -- "INSERT INTO users (Fname, Lname, Username, Email, Password)Values('$Fname', '$LName', '$Username', '$Email', '$PW')" Commented Nov 6, 2015 at 12:20
  • you are using procedural style and object oriented style..... !!!!!!! Commented Nov 6, 2015 at 12:22
  • PHP is case sensitive. $_POST needs to be in capitals. You have if(isset($_Post['Register'])) Commented Nov 6, 2015 at 12:24
  • see -- php.net/manual/en/function.mysql-connect.php Commented Nov 6, 2015 at 12:25
  • Working now, Thank you very much! Commented Nov 6, 2015 at 13:51

2 Answers 2

0

You need to edit the Connection.php

mysql_connect("localhost", "USERNAME", "PASSWORD"); 
mysql_select_db("Registration");  //your data base name

And also you have to edit

 mysql_query("INSERT INTO users (Fname, Lname, Username, Email, Password)Values('$Fname', '$LName', '$Username', '$Email', '$PW')") or die(mysql_error());
Sign up to request clarification or add additional context in comments.

2 Comments

Working now, Thank you very much!
Please dont use the mysql_ database extension, it is deprecated (gone for ever in PHP7) Specially if you are just learning PHP, spend your energies learning the PDO database extensions. Start here its really pretty easy
0

Try this

mysql_query("INSERT INTO users (Fname, Lname, Username, Email, Password)Values('$Fname', '$LName', '$Username', '$Email', '$PW')") or die(mysql_error());

1 Comment

Please dont use the mysql_ database extension, it is deprecated (gone for ever in PHP7) Specially if you are just learning PHP, spend your energies learning the PDO database extensions. Start here its really pretty easy

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.