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????

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

Differentiate echo vs. Print statement.

720


How I can control asset documents without GR/IR?

1393


Does facebook use php framework?

779


How to create a text file in PHP?

849


Tell me how the result set of mysql be handled in php?

702


How many types of array supported in php?

726


What is sticky form in php?

665


How to turn on the session support?

826


What is difference between web service and api?

718


What is 'float' property in css?

777


What are the disadvantages of php?

710


Is key in array php?

746


What difference between require() and require_once()?

799


What is php? Why it is used?

757


What is list function with their uses.

715