-1

Here is my error:

Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\bookstore\main\sign_up.php on line 17

Here is the code:

<?php
    session_start();
    include('page_edit.php');
    if(isset($_POST ['signup'])){
        $fullname = $_POST['fname'];
        $username = $_POST['uname'];
        $email = $_POST['em'];
        $country= $_POST['con'];
        $password = $_POST['pw'];
        $gender= $_POST['gender'];

    $query = "INSERT INTO `bookstore`.`log_in` (`ID`, `fullname`, `email`, `country`,`Username`, `Password`,`gender`)";

mysql_query($query) or die(mysql_error());
header("location:index.php");
?>
halfer
  • 19,824
  • 17
  • 99
  • 186
  • 1
    Welcome. You will also want to investigate and protect your inputs from SQL Injection. Check out MySQLi or PDO and start using prepared statements. If this code is in the wild, it would be vulnerable. – Twisty Apr 17 '15 at 16:58
  • @inuxvd: thanks for wanting to add improvements to questions. However, you've added a spelling error, and are reformatting code, which can sometimes hide the cause of a problem. Unless an OP's code is _really_ unreadable, I advise leaving the code portion alone. – halfer Apr 17 '15 at 17:00

3 Answers3

2

You're missing the closing } for the if block.

if(isset($_POST ['signup'])){
    ...
    ...
} // <-- missing

Once that is fixed, you'll find that it doesn't insert your data, because you're not passing any values to the INSERT query. Switch to PDO or MySQLi and use a prepared statement to insert the user input.

MrCode
  • 63,975
  • 10
  • 90
  • 112
0

You missed a closing bracket for if condition.

 if(isset($_POST ['signup']))
{
        $fullname = $_POST['fname'];
        $username = $_POST['uname'];
        $email = $_POST['em'];
        $country= $_POST['con'];
        $password = $_POST['pw'];
        $gender= $_POST['gender'];

    $query = "INSERT INTO `bookstore`.`log_in` (`ID`, `fullname`, `email`, `country`,`Username`, `Password`,`gender`)";

    mysql_query($query) or die(mysql_error());
    header("location:index.php");
} // closing if condition here

WARNING :

mysql is deprecated. Use mysqli or PDO. Your code is vulnerable to SQL Injection.

Yuva Raj
  • 3,881
  • 1
  • 19
  • 30
0

The correct code is

<?php
    session_start();
    include('page_edit.php');
    if(isset($_POST ['signup'])){
        $fullname = $_POST['fname'];
        $username = $_POST['uname'];
        $email = $_POST['em'];
        $country= $_POST['con'];
        $password = $_POST['pw'];
        $gender= $_POST['gender'];

    $query = "INSERT INTO `bookstore`.`log_in` fields (`ID`, `fullname`, `email`, `country`,`Username`, `Password`,`gender`) values ({Put all variables here})";

mysql_query($query) or die(mysql_error());
header("location:index.php");
}
    ?>
Manish Shukla
  • 1,355
  • 2
  • 8
  • 21