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

What is list in PHP?

642


How to convert one date format into another in php?

483


Write logic to print Floyd's triangle in PHP?

542


How many different types of messages available in php?

545


How to increase the execution time of a PHP script?

524






How to get a random value from a php array?

549


What are the advantages of triggers in php?

477


Tell me is it possible to submit a form with a dedicated button?

527


What is the difference between php and cakephp?

523


What are the steps involved to run php?

570


How we can retrieve the data in the result set of mysql using php?

522


When a conditional statement is ended with an endif?

517


What is strlen php?

543


How many types of functions are there in php?

596


Is age a variable in research?

485