0

i have used the bootstrap inline form. Here's the code:

<form class="form-inline" action="php/signup.php" method="post">
                <div class="form-group">
                    <label class="sr-only" for="firstname">First name</label>
                    <input type="text" required class="form-control" id="exampleInputEmail2" name="firstname" placeholder="First name">
                </div>
                <div class="form-group">
                    <label class="sr-only" for="middlename">Middle name</label>
                    <input type="text" class="form-control" id="exampleInputEmail2" name="middlename" placeholder="Middle name">
                </div>
                <div class="form-group">
                    <label class="sr-only" for="lastname">Last name</label>
                    <input type="text" required class="form-control" id="exampleInputPassword2" name="lastname" placeholder="Last name">
                </div>


                <br/>
                <br/>

                <div class="form-group">
                    <label class="sr-only" for="username">User name</label>
                    <input type="text" required class="form-control" id="exampleInputPassword2" name="username" placeholder="Desired user name">
                </div>

                <br/>
                <br/>

                <div class="form-group">
                    <label class="sr-only" for="password">Password</label>
                    <input type="password" required class="form-control" id="exampleInputPassword2" name="password" placeholder="Password">
                </div>

                <br/>
                <br/>

                <div class="form-group">
                    <label class="sr-only" for="repassword">Re enter password</label>
                    <input type="password" required class="form-control" id="exampleInputPassword2" name="repassword" placeholder="Re enter password">
                </div>

                <br/>
                <br/>

                <div class="form-group">

                    <input type="email" required class="form-control" id="exampleInputPassword2" name="email" placeholder="E-mail address">
                </div>

                <br/>
                <br/>

                <button type="submit" name="btnSubmit"> Sign up</button>
        </form>

I also a PHP backend for submitting the form data:

<?php
session_start();
include("connect_to_mysql.php");
if(isset($_POST("btnSubmit")))
{
    $firstname = mysql_real_escape_string($_POST("firstname"));
    $middlename = mysql_real_escape_string($_POST("middlename"));
    $lastname = mysql_real_escape_string($_POST("lastname"));
    $username = mysql_real_escape_string("username");
    $password = mysql_real_escape_string("password");
    // check the re entered password using jquery on the client machine itself
    $email = mysql_real_escape_string("email");


    /*firstname varchar(255),
                middlename varchar(255) NOT NULL,
                lastname varchar(255) NOT NULL,*/
    $query = "create table if not exists authenlist(
                id int NOT NULL AUTO_INCREMENT,
                username varchar(255) NOT NULL,
                password varchar(255) NOT NULL,
                PRIMARY KEY (id))";

    $i = mysql_query($query) or die("authentication table not created");

    if($i)
    {
        $query = "select * from authenlist where username='$username'";

        $o = mysql_query($query) or die("query not executed");

        if($o)
        {
            if(mysql_num_rows($o) == 0)
            {
                $query = "insert into authenlist values('', '$username', '$password')";
                $_SESSION['username']=$username;//to register user
                header("location:home.php");
                exit();
            }
            else
            {
                header("status: 404 not found");
            }
        }
    }
}
?>

When i try to submit the form there is always a fatal error: Fatal error: Can't use function return value in write context in C:\wamp\www\the_unknown\php\signup.php on line 4.

I am unable to understand what is the error in the process of form submission. I am in immediate need of this form and I really need it to work. Please can somebody help me out with the problem I am facing. Thanks in advance.

7
  • so what's on line 4 in your signup.php ? Commented Mar 7, 2014 at 6:46
  • And PLEASE dont use mysql functions, they will be removed in the next major version ... (hopefully). Use PDO or at least mysqli Commented Mar 7, 2014 at 6:47
  • @DrixsonOseña if(isset($_POST("btnSubmit"))) Commented Mar 7, 2014 at 6:47
  • Remove that if statement and see what happens. Does it get executed as required? Commented Mar 7, 2014 at 6:49
  • 1
    as answer below $_POST() is not a function but a collection of data so you should access it $_POST['index'] as an array Commented Mar 7, 2014 at 6:50

1 Answer 1

3

$_POST("btnSubmit") is wrong

Use

$_POST["btnSubmit"]

It is any array

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.