i have designed a registration form in html
(registration.html) and to insert user details in database
i have designed a submit form in php
(submit_registration.php) but when i click on submit button
in registration.html it opens a dialogue box which asks for
open or save php(submit_registration.php) even though i
have already installed apache HTTP server and php version 5
on my computer and i am using mysql as backend.

plz suggest me what should i do????

Answers were Sorted based on User's Feedback



i have designed a registration form in html (registration.html) and to insert user details in datab..

Answer / approacher

file name shouldnot be "registration.html" but
"registration.php"

Is This Answer Correct ?    3 Yes 0 No

i have designed a registration form in html (registration.html) and to insert user details in datab..

Answer / pohit

<html>
<table width="300" border="2" align="center"
cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="loginform" method="post" action="insert.php">
<td>
<table width="100%" border="1" cellpadding="3"
cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td><strong>Member Login </strong></td>
</tr>
<tr>
<td align="center"><strong>FirstName</strong></td>
<td align="center"><strong>:</strong></td>
<td align="center"><input name="FirstName" type="text"
id="FirstName" /></td>
</tr>
<tr>
<tr>
<td align="center"><strong>LastName</strong></td>
<td align="center"><strong>:</strong></td>
<td align="center"><input name="LastName" type="text"
id="LastName" /></td>
</tr>
<td align="center"><strong>Email</strong></td>
<td align="center"><strong>:</strong></td>
<td align="center"><input name="Email" type="text"
id="Email" /></td>
</tr>
<tr>
<td align="center"><strong>Password</strong></td>
<td align="center"><strong>:</strong></td>
<td align="center"><input type="Password" name="Password"
id="Password" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit"
value="Submit" /></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
</html>
<?php
include("includes/config.php");
$FirstName=$_POST['FirstName'];
$LastName=$_POST['LastName'];
$Email=$_POST['Email'];
$Password=$_POST['Password'];
if(isset($_REQUEST['Submit']))
{
$sql="INSERT INTO myvalues (FirstName, LastName, Email,
Password ) VALUES
('$FirstName', '$LastName', '$Email', '$Password')";
$result=mysql_query($sql);
if($result)
{
echo "Successful";
echo "<BR>";
echo "<a href='insert.php'>Back to main page</a>";
}
else {
echo "ERROR";
}
}

?>

Is This Answer Correct ?    2 Yes 0 No

i have designed a registration form in html (registration.html) and to insert user details in datab..

Answer / guru

<?php
error_reporting('E_ALL ^ E_NOTICE');
if(isset($_POST['submit']))
{
mysql_connect('localhost','root','') or die(mysql_error());
mysql_select_db('new') or die(mysql_error());
$name=$_POST['name'];
$password=$_POST['password'];
$mail=$_POST['mail'];
$q=mysql_query("select * from login where name='".$name."' or mail='".$mail."' ") or die(mysql_error());
$n=mysql_fetch_row($q);
if($n>0)
{
$er='The username name '.$name.' or mail '.$mail.' is already present in our database';
}
else
{
$insert=mysql_query("insert into login values('".$name."','".$password."','".$mail."')") or die(mysql_error());
if($insert)
{
$er='Values are registered successfully';
}
else
{
$er='Values are not registered';
}
}
}
?>
<div class="contact">
<h1>Registration Form</h1>
<div id="er"><?php echo $er; ?></div>
<form action="#" method="post">
<table id="tbl" align="center">
<tr><td>Name:</td><td><input type="text" name="name" id="name"></td></tr>
<tr><td>Password:</td><td><input type="text" name="password" id="password"></td></tr>
<tr><td>Email:</td><td><input type="text" name="mail" id="mail"></td></tr>
<tr><td></td><td><input type="submit" name="submit" id="submit" value="Submit"></td></tr>
</table>
</form>
</div>

<script type="text/javascript">
$(document).ready(function() {
$('#submit').click(function() {
var name=document.getElementById('name').value;
var password=document.getElementById('password').value;
var mail=document.getElementById('mail').value;
var chk = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
if(name=='')
{
$('#er').html('Enter your name');
return false;
}
if(password=='')
{
$('#er').html('Enter your password');
return false;
}
if(mail=='')
{
$('#er').html('Enter your mail');
return false;
}
if(!chk.test(mail))
{
$('#er').html('Enter valid email');
return false;
}
});
});
</script>
<

Reference: http://www.phponwebsites.com/2014/07/php-mysql-create-registration-sign-up-form.html

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More PHP Interview Questions

Does cors prevent csrf?

0 Answers  


i got 2 year backs in my MCA,i am 28 year guy, presently learning PHP, can i get the job & on facing the interview wht i will answer out for that?? (experience in as a 1.5yr System analyst after graduation)

0 Answers  


Does php have block scope?

0 Answers  


What is polymorphism with example in php?

0 Answers  


What is singleton design pattern in php?

0 Answers  






What is regex in html?

0 Answers  


How does php session work?

0 Answers  


Why we are using PHP than others for web developing?

4 Answers  


What is cookie?

0 Answers  


How to strip whitespace (or other characters) from the beginning and end of a string?

0 Answers  


Why do we use polymorphism in php?

0 Answers  


Is php better than java?

0 Answers  


Categories