How to create Registration Page in Php

121

<?php
session_start();
require 'conf.php';
error_reporting(0);
$db=new db();
$msg='';
if(isset($_POST['submit'])) {
//print_r($_POST);exit;
$cityzenship=$_POST['cityzenship'];
$age=$_POST['age'];
$sex=$_POST['sex'];
$socialdis=$_POST['socialdis'];
$subcat=$_POST['subcategories'];

$subcategories=implode(',', $subcat);
$sql="select *from registration where email='$email'";
$run=mysql_query($sql);
$num=mysql_num_rows($run);
if($num!=0)
{

$msg="Email Already Exist";

}
else
{
$as1="INSERT INTO registration SET cityzenship='$cityzenship', age='$age', sex='$sex',socialdis='$socialdis', fundinglook='$fundinglook',moneytext='$moneytext',idealcantext='$idealcantext',fname='$fname',lname='$lname',streetadd='$streetadd',city='$city',state='$state',zip='$zip',fphone='$fphone',mphone='$mphone',lphone='$lphone',email='$email',checkbox='$checkbox',category='$cat',subcategory='$subcategories'";
$que1=mysql_query($as1) or die(mysql_error());
if($que1){
$id=mysql_insert_id();

$_SESSION['user_id']=$id;
}
header('location:inner_page.php');

}
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script>
function validate(){

var cityzenship = document.getElementById('cityzenship');
if(cityzenship.options[cityzenship.selectedIndex].value == "")
{
document.getElementById('citizen_error').style.display="inline";
document.getElementById('cityzenship').focus();
return false;
}


var age = document.getElementById('age').value;
var numbers = /^[0-9]+$/;
if(age.match(numbers))
{


}
else
{
hideAllErrorssign();
document.getElementById('age_error').style.display="inline";
document.getElementById('age').focus();
return false;
}

var age = document.getElementById('age').value;
if(age>=111){
hideAllErrorssign();
document.getElementById('aage_error').style.display="inline";
document.getElementById('age').focus();
return false;
}


if((document.getElementById('male').checked==false) &&(document.getElementById('female').checked==false))
{
document.getElementById('male_error').style.display="inline";
document.getElementById('male').focus();
return false;
}

if((document.getElementById('yes').checked==false)&&(document.getElementById('no').checked==false))
{

document.getElementById('social_error').style.display="inline";
document.getElementById('yes').focus();
return false;
}


var funding = document.getElementById('fund');
if(funding.options[funding.selectedIndex].value == "")
{
document.getElementById('fund_error').style.display="inline";
document.getElementById('fund').focus();
return false;
}



var money = document.getElementById('money').value;
if(money==''){
document.getElementById('money_error').style.display="inline";
document.getElementById('money').focus();
return false;
}

var idealcandi = document.getElementById('idealcandi').value;
if(idealcandi==''){
document.getElementById('idealcandi_error').style.display="inline";
document.getElementById('idealcandi').focus();
return false;
}


var firstname = document.getElementById('fname').value;
var letterss = /^[A-Za-z]+$/;
if(firstname.match(letterss))
{

}
else
{
document.getElementById('firstname_error').style.display="inline";
document.getElementById('fname').focus();
return false;
}




var lastname = document.getElementById('lname').value;
if(lastname=='')
{
document.getElementById('lastname_error').style.display="inline";
document.getElementById('lname').focus();
return false;
}

var city = document.getElementById('city').value;
if(city=='')
{
document.getElementById('city_error').style.display="inline";
document.getElementById('city').focus();
return false;
}




var state = document.getElementById('state');
if(state.options[state.selectedIndex].value == "")
{

document.getElementById('state_error').style.display="inline";
document.getElementById('state').focus();
return false;
}

var zip = document.getElementById('zip').value;
var numbersssss = /^[0-9]+$/;
if(zip.match(numbersssss))
{


}
else
{
hideAllErrorssign();
document.getElementById('zip_error').style.display="inline";
document.getElementById('zip').focus();
return false;
}
if(zip.length==6)
{

}
else{
hideAllErrorssign();
document.getElementById('zip_errorrs').style.display="inline";
document.getElementById('zip').focus();
return false;
}

var streetadd = document.getElementById('streetadd').value;

if(streetadd=='')
{
document.getElementById('streetadd_error').style.display="inline";
document.getElementById('streetadd').focus();
return false;
}

var fphone = document.getElementById('fphone').value;
var numberss = /^[0-9]+$/;
if(fphone.match(numberss)){

}
else{
hideAllErrorssign();
document.getElementById('fphone_error').style.display="inline";
document.getElementById('fphone').focus();
return false;
}


var mphone = document.getElementById('mphone').value;
var numbersss = /^[0-9]+$/;
if(mphone.match(numbersss))
{

}
else{
hideAllErrorssign();
document.getElementById('mphone_error').style.display="inline";
document.getElementById('mphone').focus();
return false;
}




var lphone = document.getElementById('lphone').value;
var numberssss = /^[0-9]+$/;
if(lphone.match(numberssss))
{
}
else
{
hideAllErrorssign();
document.getElementById('lphone_error').style.display="inline";
document.getElementById('lphone').focus();
return false;
}

var email = document.getElementById('email').value;
if(email==''){
hideAllErrorssign();
document.getElementById('email_error').style.display="inline";
return false;
}

else
{
var regexp=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if(!(email.match(regexp)))
{
hideAllErrorssign();
document.getElementById('emailcorrect_error').style.display="inline";
return false;
}

}

}

function myFunction(){
var x = document.getElementById('fphone').value;
if(x.length==3){
document.getElementById('mphone').focus();
}

var y = document.getElementById('mphone').value;
if(y.length==3){
document.getElementById('lphone').focus();

}

}

function hideAllErrorssign()
{
document.getElementById("citizen_error").style.display = 'none';
document.getElementById('age_error').style.display="none";
document.getElementById('aage_error').style.display="none";
document.getElementById('male_error').style.display="none";
document.getElementById('social_error').style.display="none";
document.getElementById('fund_error').style.display="none";

document.getElementById('money_error').style.display="none";
document.getElementById('idealcandi_error').style.display="none";

document.getElementById('firstname_error').style.display="none";

document.getElementById('lastname_error').style.display="none";

document.getElementById('streetadd_error').style.display="none";
document.getElementById('state_error').style.display="none";
document.getElementById('zip_error').style.display="none";

document.getElementById('fphone_error').style.display="none";
document.getElementById('mphone_error').style.display="none";

document.getElementById('lphone_error').style.display="none";
document.getElementById('llphone_error').style.display="none";
document.getElementById('email_error').style.display="none";
document.getElementById('emailcorrect_error').style.display="none";
document.getElementById('emailexist_error').style.display="none";

}

</script>

<script language="javascript" type="text/javascript">
function getXMLHTTP() { //fuction to return the xml http object
var xmlhttp=false;
try{
xmlhttp=new XMLHttpRequest();
}
catch(e) {
try{
xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e1){
xmlhttp=false;
}
}
}
return xmlhttp;
}

function check_email()
{
//alert("helloo");
var request = getXMLHTTP();
var email=document.getElementById('email').value;
request.open('GET', 'check_email_exist.php?email=' + email, true);
request.onreadystatechange=function(){
if (request.readyState == 4) {
if (request.status == 200) {
var response = request.responseText; //alert(response);
if (response == 'yes') {
document.getElementById("email_error").style.display = "none";
document.getElementById('emailcorrect_error').style.display = "none";
document.getElementById('emailexist_error').style.display = 'inline';
er_status=1;
document.getElementById('email').focus();
return false;
} else {
er_status = '0';
document.getElementById('emailexist_error').style.display = 'none';
}

}
}
}
request.send(null);
}

</script>

<title>Access American</title>
<link href="css/style.css" type="text/css" rel="stylesheet" />
<link href="css/style2.css" type="text/css" rel="stylesheet" />
</head>

<body>
<div id="wrapper">
<div id="Container">
<div class="logo"><a href="#"><img src="images/logo.png" border="0" /></a> </div>
<div class="banner"><img src="images/banner.png" /></div>
<div id="Middle_contr">
<div class="middle_contr_left">

<div class="middle_in_contr">

<form name="registration" method="post" enctype="multipart/form-data" >
<div class="middle_in_contr_img" id="div1" onclick="document.getElementById('personal').checked = true; window.location='#form'"><input name="category" type="radio" value="Personal" style="position:absolute; margin:30px 0px 0px 10px;" id="personal" onclick="switchid('a1','div1'); " /><a href="javascript:void(0);" onclick="switchid('a1','div1');"><img src="images/img1.png" border="0" id="aa1" /></a></div>
<div class="middle_in_contr_img" id="div4" onclick="document.getElementById('business').checked = true; window.location='#form'" ><input name="category" type="radio" value="Real estate" style="position:absolute; margin:30px 0px 0px 10px;" id="business" onclick="switchid('a4','div4');" /><a href="javascript:void(0);" onclick="switchid('a4','div4');"><img src="images/img4.png" border="0" id="aa4" /></a></div>
<a name="form"></a>

<div class="clear"></div>
<div class="login_contr">

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="46%">citizenship</td>
<td width="25%">age</td>
<td colspan="4">gender</td>
</tr>
<tr>
<td valign="top"> <select class="login_contant_select" name="cityzenship" id="cityzenship"><option value="">Select</option>
<option value="U.S.Citizen">U.S.Citizen</option>
<option value="Resident Alien">Resident Alien</option>
<option value="Green Card Holder">Green Card Holder</option>
<option value="Permanent Resident">Permanent Resident</option>
<option value="Not Sure">Not Sure</option></select>
<span id="citizen_error" style="color:#FF0000; float:left; display:none" >*Please enter correct citizenship</span>
</td>
<td valign="top"><input type="text" name="age" class="login_contant_input" style="width:115px;" id="age" />
<span id="age_error" style="color:#FF0000; float:left; display:none" >*Please enter correct age</span>
<span id="aage_error" style="color:#FF0000; float:left; display:none" >*Should be less than 110</span>
</td>
<td width="3%" ><input type="radio" name="sex" id="male" value="male" />

</td>
<td width="8%" >male</td>
<td width="4%" ><input type="radio" name="sex" id="female" value="female" />

<span id="male_error" style="color:#FF0000; float:left; display:none;" >*Select Gender</span> </td>
<td width="14%" >female</td>
</tr>
<tr>
<td colspan="6" >&nbsp;</td>
</tr>
<tr>
<td colspan="6">Are you thinking about applying for social security disability?</td>
</tr>
<tr>
<td colspan="6">&nbsp;</td>
</tr>
<tr>
<td colspan="6"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="4%" valign="top"><input type="radio" name="socialdis" id="yes" value="yes" />
</td>
<td width="12%">yes</td>
<td width="4%" valign="top"><input type="radio" name="socialdis" id="no" value="no" />
<span id="social_error" style="color:#FF0000; float:left; display:none" >*Please select one of both</span></td>
<td width="80%">no</td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="6">&nbsp;</td>
</tr>
<tr>
<td colspan="6">How much funding are you looking for?</td>
</tr>
<tr>
<td colspan="6" valign="top"><select class="login_contant_select" name="fundinglook" id="fund">
<option value="">select</option>
<option value="$500 to $10,000">$500 to $10,000</option>
<option value="$100,000 or More">$100,000 or More</option></select>
</select>
<span id="fund_error" style="color:#FF0000; float:left; display:none" >*Please select one</span>
</td>

</tr>
<tr>
<td colspan="6">&nbsp;</td>
</tr>
<tr>
<td colspan="6">Describe in detail how you'll use the money:</td>
</tr>
<tr>
<td colspan="6" valign="top"><textarea class="login_contant_select2" name="moneytext" id="money" ></textarea><span id="money_error" style="color:#FF0000; float:left; display:none" >*Please write few words</span>
</td>
</tr>


<tr>
<td colspan="6">&nbsp;</td>
</tr>
<tr>
<td colspan="6">What makes you the ideal candidate for this funding?</td>
</tr>
<tr>
<td colspan="6" valign="top"><textarea class="login_contant_select2" name="idealcantext" id="idealcandi"></textarea><span id="idealcandi_error" style="color:#FF0000; float:left; display:none" >*Please write few words</span>
</td>
</tr>

<tr>
<td colspan="6">&nbsp;</td>
</tr>
<tr>
<td colspan="6"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="49%">first name</td>
<td width="51%">last name</td>
</tr>
<tr>
<td valign="top"><input type="text" name="fname" class="login_contant_input" id="fname"/>
<span id="firstname_error" style="color:#FF0000; float:left; display:none" >*Please fill correct first name</span></td>
<td valign="top"><input type="text" name="lname" class="login_contant_input" id="lname"/>
<span id="lastname_error" style="color:#FF0000; float:left; display:none" >*Please fill correct last name</span></td>

</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>
<td width="42%" >city</td>
<td width="27%" >state</td>
<td width="31%" >zip</td>
</tr>
<tr>
<td valign="top"><input type="text" name="city" class="login_contant_input" style="width:200px;" id="city"/>
<span id="city_error" style="display:none; font-size:12px; color:#FF0000;">*Please Enter City</span></td>
<td valign="top"><select class="login_contant_select" name="state" id="state" style="width:130px;"><option value="">Select</option>
<option value="Alabama">Alabama</option>
<option value="Wyoming" >Wyoming</option></select>
<span id="state_error" style="display:none; font-size:12px; color:#FF0000;">*Please Enter State</span></td>
<td valign="top"><input type="text" name="zip" class="login_contant_input" style="width:115px;"id="zip" maxlength="6"/>
<span id="zip_error" style="display:none; float:left; font-size:12px; color:#FF0000;" zip_errorrs>*Must be integer</span>
<span id="zip_errorrs" style="display:none; float:left; font-size:12px; color:#FF0000;" zip_errorrs>*Must be 6 digits</span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>

<tr>
<td colspan="2">street address</td>
</tr>
<tr>
<td colspan="2" valign="top"><input type="text" name="streetadd" class="login_contant_input" id="streetadd" style="width:518px;"/>
<span id="streetadd_error" style="color:#FF0000; float:left; display:none" >*Please fill address</span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="6">&nbsp;</td>
</tr>
<tr>
<td colspan="6"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="12%" valign="top"><input type="text" name="fphone" class="login_contant_input" id="fphone" style="width:50px;" maxlength="3" onkeyup="myFunction()" /><span id="ffphone_error" style="color:#FF0000; float:left; display:none" >Should be 3 digit</span> <span id="fphone_error" style="color:#FF0000; float:left; display:none" >*Should be integer</span></td>
<td width="3%" align="center">-</td>
<td width="12%" valign="top"><input type="text" name="mphone" class="login_contant_input" id="mphone" style="width:50px; " maxlength="3" onkeyup="myFunction()"/> <span id="mphone_error" style="color:#FF0000; float:left; display:none" >Should be integer</span><span id="mmphone_error" style="color:#FF0000; float:left; display:none" >*Should be 3 digit</span></td>
<td width="3%" align="center">-</td>
<td width="19%" valign="top"><input type="text" name="lphone" class="login_contant_input" id="lphone"style="width:50px; " maxlength="4"/>
<span id="lphone_error" style="color:#FF0000; float:left; display:none" >*Should be integer</span>
<span id="llphone_error" style="color:#FF0000; float:left; display:none" >*Should be 4 digit</span>
</td>
<td width="51%" valign="top"><input type="text" name="email" id="email" class="login_contant_input" onblur="return check_email();" />
<span id="email_error" style="color:#FF0000; float:left; display:none" >*Please enter email</span>
<span id="emailcorrect_error" style="color:#FF0000; float:left; display:none" >*Please enter correct email</span><br /><br>
<!-- <div style="color:#FF0000; font-size:12px; padding:0px 11px 0px 0px;"><?php //echo $msg ; ?></div>--->
<span id="emailexist_error" style="color:#FF0000; float:left; display:none" >*email exist</span>


</td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="6">&nbsp;</td>
</tr>
<tr>
<td colspan="6"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="5%">
<input type="checkbox" name="checkbox" id="checkbox" value="yes"/>
</td>
<td width="95%">Yes, inform me of new funding opportunities!</td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="6">
<div style=" margin:20px 0 20px 130px;">
<input type="submit" class="button2" name="submit" value="complete registration" onclick="return validate();" />
</div></td>
</tr>
</table>
</form>
<?php
session_start();
session_unset($_SESSION['user_id']);
if($_SESSION['user_id']=="")
{
header('location:index.php');
}
?>
<?php
//Ajax file
require 'conf.php';
$db= new db();
$email=$_GET['email'];
$result=mysql_query("select email from registration where email='$email'") or die(mysql_error());
$num=mysql_num_rows($result);
if($num>0){
echo "yes";
}else{
echo "no";
}

?>
// manange file
<td nowrap="nowrap" align="center">
<a href="view_category.php?id=<?php echo $w['id'];?>"><img src="images/view.jpg" alt="View" title="View Category"></a>
<a href="edit_category.php?id=<?php echo $w['id'];?>"><img src="images/edit.jpg" alt="Edit" title="Edit Category"/></a>
<a href="" class="delbutton" id="<?=$w['id'];?>" title="Delete" onclick="return confirm('Do You want to delete !');"><img src="images/delete.jpg" alt="delete" title="Delete" /> </a>
</td>
<?php
if(isset($_GET['delid'])){
$id=$_GET['delid'];
$sql = "DELETE FROM `categories` WHERE `id`='$id'";
mysql_query($sql);
}
?>
//// View file
<?php
session_start();
if($_SESSION['admin_id']==''){
header("Location:index.php");
exit;
}

if(isset($_GET['uid'])) {
$uid=$_GET['uid'];
}
$sql=mysql_query("select * from `categories` where `id`='".$_GET['id']."'");
$res=mysql_fetch_array($sql);
?>
// edit file
<?php
ob_start();
session_start();
include_once("../config/db.php");
//require_once("thumbnail.inc.php");
include('SimpleImage.php');

if($_SESSION['admin_id']==''){
header("Location:index.php");
exit;
}

$db= new db();

$msg='';
if(isset($_GET['id'])) {
$catId = $_GET['id'];
}

//$res=mysql_query("select * from users where users_id='$userId'");
//$record=mysql_fetch_array($res);

$sql = mysql_query("select * from `categories` Where `id`='".$catId."'");
$res = mysql_fetch_array($sql);
if(isset($_POST['submit'])) {
$name=$_POST['cat_name'];
$desc=$_POST['desc'];
$status = $_POST['status'];
$as1="update categories set category_name = '$name', category_desc = '$desc', status='$status' where id='$catId'";
$que1 = mysql_query($as1) or die(mysql_error());
header("location: manage_categories.php");
exit;
}
?>

LEAVE A REPLY

Please enter your comment!
Please enter your name here