Index.php
<html>
<head><title>Registration</title>
<script type="text/javascript">
function numbersonly(e,length){
var unicode=e.charCode? e.charCode : e.keyCode
var maxlength=length;
if (unicode!=8){ //if the key isn't the backspace key (which we should allow)
if (unicode<48||unicode>57) //if not a number
return false //disable key press
}
}
</script>
<script type="text/javascript">
function validation()
{
var a = document.form.phone.value;
if(a=="")
{
alert("Please Enter Your Phone Number");
document.form.phone.focus();
return false;
}
}
</script>
<script type="text/javascript">
var reg = /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/;
function PhoneValidation(phone)
{
var OK = reg.exec(phone.value);
if (!OK)
window.alert("phone number isn't valid");
else
window.alert("phone number is valid");
}
</script>
<script language="javascript">
function checkEmail() {
var email = document.getElementById('email');
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{3})+$/;
if (!filter.test(email.value)) {
alert('Please provide a valid email address');
email.focus;
return false;
}
}</script>
</head>
<body>
<div align="center">
<h3> Registration</h3>
<form name="register" action="save.php" enctype="multipart/form-data" onsubmit="return validation()" method="post">
<label>Name</label>
<label>:</label>
<input type="text" name="name" id="name" placeholder="Name" required/><br /><br />
<label>Email</label>
<label>:</label>
<input type="email" name="email" id="email" placeholder="Email" required/><br /><br />
<label>Password</label>
<label>:</label>
<input type="password" name="password" id="password" placeholder="Password" required/><br /><br />
<label>RepeatPassword</label>
<label>:</label>
<input type="password" name="repeatpassword" id="repeatpassword" placeholder="RepeatPassword" required/><br /><br />
<label>Date of Birth</label>
<label>:</label>
<select name="day" required>
<option value="">Day</option>
<?php for ($day = 1; $day <= 31; $day++) { ?>
<option value="<?php echo strlen($day)==1 ? '0'.$day : $day; ?>"><?php echo strlen($day)==1 ? '0'.$day : $day; ?></option>
<?php } ?>
</select>
<select name="month" required>
<option value="">Month</option>
<?php for ($month = 1; $month <= 12; $month++) { ?>
<option value="<?php echo strlen($month)==1 ? '0'.$month : $month; ?>"><?php echo strlen($month)==1 ? '0'.$month : $month; ?></option>
<?php } ?>
</select>
<select name="year" required>
<option value="">Year</option>
<?php for ($year = date('Y'); $year > date('Y')-100; $year--) { ?>
<option value="<?php echo $year; ?>"><?php echo $year; ?></option>
<?php } ?>
</select><br /><br />
<label>Phone</label>
<label>:</label>
<input type="text" name="phone" id="phone" placeholder="Phone No" maxlength="10" onKeyPress="return numbersonly(event)" onchange="PhoneValidation(this);" required/><br /><br />
<input type="submit" name="submit" value="Register" onClick="return checkEmail()"/>
</form>
</div>
</body>
</html>
save.php:::
<?php
include('connect.php');
$name=$_POST['name'];
$email=$_POST['email'];
$password=$_POST['password'];
$repeatpassword=$_POST['repeatpassword'];
$phone=$_POST['phone'];
$date = $_POST['day'] . '/' . $_POST['month'] . '/' . $_POST['year'];
$sql=mysql_query("insert into register(name,email,password,repeatpassword,phone,date)values('$name','$email','$password','$repeatpassword','$phone','$date')") or die(mysql_error());
echo "<script type='text/javascript'>alert('Data Inserted Successfully'); window.location.href='index.php';</script>";
?>
my question is, it inserts all the values in the database except date of birth,
values are storing like :
id username email password repeatpassword phone date
7 akbar akbarbai@gmail.com baiakbar baiakbar 2147483647 0000-00-00.
How to solve this...
I need:
7 akbar akbarbai@gmail.com baiakbar baiakbar 2147483647 20/12/2015
AntonyRayan 15 Posting Whiz in Training
pritaeas 2,194 ¯\_(ツ)_/¯ Moderator Featured Poster
mattster 195 Practically a Master Poster Featured Poster
AntonyRayan 15 Posting Whiz in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.