Reputation: 283
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.
Upvotes: 0
Views: 113
Reputation: 35404
$_POST("btnSubmit")
is wrong
Use
$_POST["btnSubmit"]
It is any array
Upvotes: 3