Forum Moderators: coopster
I am a complete newbie. I have been working on a self-learning project that will ask users for three strings (i.e. name,dob and number. If details are correct, will vector to a new page and display all their other information unique to their name,dob and number. The second page will then display their school,work,address, etc. which is editable. They will then click the submit button at the bottom to save the displayed data (or any changes they made to it) in the database from where it was initially extracted from.
Here is the php for the first page which asks the name,dob and number:
<?
$error="";
if(isset($_POST['submit_form']))
{
$k=$_POST['k'];
$sur_name=$_POST['sur_name'];
$dob=$_POST['dob'];
$membership_id_number=$_POST['membership_id_number'];
$mselect="select * from `userinfo` where `Membership_ID_Number`='$membership_id_number'";
$mquery=mysql_query($mselect);
$mresult=mysql_fetch_array($mquery);
$num=mysql_num_rows($mquery);
if($num>0)
{
$userid=$mresult[1];
$select="select sur_name,dob from members where sur_name='$sur_name' and dob='$dob' and id='$userid'";
$query=mysql_query($select);
$fetch=mysql_fetch_array($query);
if($dob==$fetch[1])
{
$uer_id=$userid;
$sql="select * from payment where user_id='$uer_id'";
$query1111=mysql_query($sql);
$result=mysql_fetch_array($query1111);
echo "nod=".$nod=$result[3];
$pay_date=$result[5];
$paydate=explode(" ",$pay_date);
$fulltime2=$paydate[0];/////
$fulltime1=explode(":",$fulltime2);
$hours=$fulltime1[0];
$minute=$fulltime1[1];
$second=$fulltime1[2];
$month=$paydate[1];
$day2=$paydate[2];/////
$day1=explode(",",$day2);
$day=$day1[0];
$year=$paydate[3];
$days=floor((time()-mktime($hours,$minute,$second,$month,$day,$year))/86400);
$_SESSION['id']=session_id();
$_SESSION['Membership_ID_Number']=$userid;
if($nod<=$days)
{
$sql1="update `members` set `status`='0' where `Membership_ID_Number`='$userid'";
$query1=mysql_query($sql1);
session_unset();
session_destroy();
echo '<SCRIPT LANGUAGE="JavaScript">alert ("Your Membership Period is Expired. Please renew your membership");</SCRIPT>';
echo "<script language='javascript'>location.href='index.php?task=prerenewdetails'</script>";
}
else
{
echo "<script language='javascript'>location.href='index.php?task=prelogin'</script>";
}
}
else
{
$k=$k+1;
$z=3-$k;
if($z!=0)
{
echo '<SCRIPT LANGUAGE="JavaScript">alert ("Wrong details have been entered. Please give correct details to get access. You have '.$z.' more chance left");</SCRIPT>';
}
if($z==0)
{
echo '<SCRIPT LANGUAGE="JavaScript">alert ("You have crossed your limit. Try it again later");</SCRIPT>';
echo "<script language='javascript'>location.href='index.php'</script>";
}
}
}
}
?>
This is the code for the second file which is giving me a blank output and is causing me to go crazy and frustrated:
<?
$uer_id=$_GET['userid'];
if(isset($_POST['submit_form']))
{
$first_name=$_POST['first_name'];
$mid_name=$_POST['mid_name'];
$sur_name=$_POST['sur_name'];
$day=$_POST['day'];
$month=$_POST['month'];
$year=$_POST['year'];
$dob=$year."-".$month."-".$day;
$dob1=$year."-".$month1."-".$day;
$address=$_POST['address'];
$town=$_POST['town'];
$other_town=$_POST['other_town'];
$country=$_POST['country'];
$region=$_POST['region'];
$postcode=$_POST['postcode'];
$email=$_POST['email'];
$contact1=$_POST['contact1'];
$contact2=$_POST['contact2'];
$college=$_POST['college'];
$graduated=$_POST['graduated'];
$edu1=$_POST['edu1'];
$edu2=$_POST['edu2'];
$edu3=$_POST['edu3'];
$edu_other=$_POST['edu_other'];
$edu=$edu1.",".$edu2.",".$edu3.",".$edu_other;
$prcid=$_POST['prcid'];
$prcexp=$_POST['prcexp'];
$emp_name=$_POST['emp_name'];
$emp_work=$_POST['emp_work'];
$position=$_POST['position'];
$emp_address=$_POST['emp_address'];
$emg_name=$_POST['emg_name'];
$emg_relation=$_POST['emg_relation'];
$emg_address=$_POST['emg_address'];
$emg_postcode=$_POST['emg_postcode'];
$emg_contact=$_POST['emg_contact'];
$member_applied=$_POST['member_applied'];
$m=$_POST['member_applied'];
$payment_option=$_POST['payment_option'];
$insert="UPDATE `members` SET `first_name` = '$first_name',`mid_name` = '$mid_name',`sur_name` = '$sur_name',`dob` = '$dob',`address` = '$address',`town` = '$town',`other_town` = '$other_town',`country` = '$country',`region` = '$region',`postcode` = '$postcode',`email` = '$email',`contact1` = '$contact1',`contact2` = '$contact2',`college` = '$college',`graduated` = '$graduated',`edu` = '$edu',`prcid` = '$prcid',`prcexp` = '$prcexp',`emp_name` = '$emp_name',`emp_work` = '$emp_work',`emp_address` = '$emp_address',`emg_name` = '$emg_name',`emg_relation` = '$emg_relation',`emg_address` = '$emg_address',`emg_postcode` = '$emg_postcode',`emg_contact` = '$emg_contact',`position` = '$position' WHERE `Membership_ID_Number` ='$uer_id'";
mysql_query($insert);
$insert1="update `search` set `surname`='$sur_name'";
mysql_query($insert1);
echo "<script language='javascript'>alert('Profile Updated Successfully')</script>";
echo "<script language='javascript'>location.href='index.php?task=personaldetails'</script>";
}
$select111="select * from members where Membership_ID_Number=$uer_id";
$query111=mysql_query($select111);
$fetch=mysql_fetch_row($query111);
$dob=$fetch[6];
$date=explode('-',$dob);
$year1=$date[0];
$month1=$date[1];
$day1=$date[2];
$edu=$fetch[18];
$education=explode(',',$edu);
$edu0=$education[0];
$edu1=$education[1];
$edu2=$education[2];
$edu3=$education[3];
$mselect="select * from `userinfo` where `userid`='$uer_id'";
$mquery=mysql_query($mselect);
$mresult=mysql_fetch_array($mquery);
$select_11="select * from `userinfo` where `userid`='$uer_id'";
$query_11=mysql_query($select_11);
$result_11=mysql_fetch_array($query_11);
?>
Where am i going wrong? Can somebody please guide me.
Thanks.
We have many great threads in our library that will get your started:
Basics of extracting data from mysql [webmasterworld.com]
commonly used mysql commands [webmasterworld.com]
developing mysql search query [webmasterworld.com]
Also, if you are getting any errors from the script you posted above, please paste them here.