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
Answer / approacher
file name shouldnot be "registration.html" but
"registration.php"
Is This Answer Correct ? | 3 Yes | 0 No |
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> </td>
<td> </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 |
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 |
Does cors prevent csrf?
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)
Does php have block scope?
What is polymorphism with example in php?
What is singleton design pattern in php?
What is regex in html?
How does php session work?
Why we are using PHP than others for web developing?
What is cookie?
How to strip whitespace (or other characters) from the beginning and end of a string?
Why do we use polymorphism in php?
Is php better than java?