Hey
I created this application, where a user needs to enter a code (which he has bought from me, offline), after filling up the form, he is redirected to a form.
The form checks the mysql database where a coloumn "barcode" has been where all the codes already inserted, if the code matches with a a record, that row is edited else an error is shown.
The problem is, when I try to edit a record with a valid code, it gives me the same error, please help.
The code is :
<?php
include 'connect/connect.php';
if(isset($_POST['sub'])) {
$bcode = $_SESSION['barcode_v'];
$iname = $_POST['u_name_f'].' '.$_POST['u_name_l'];
$name = stripcslashes(strip_tags($iname));
$email = $_POST['email'];
$dob = stripcslashes(strip_tags($_POST['y']."-".$_POST['m']."-".$_POST['d']));
$insti = stripcslashes(strip_tags($_POST['insti']));
$phone = $_POST['phone'];
$course = $_POST['course'];
$school = $_POST['school'];
$address = $_POST['address'];
$sql2 = "SELECT * FROM appthing WHERE barcode='$bcode'";
$query2 = mysql_query($sql2);
$row2 = mysql_fetch_array($query2);
if (!$row2[0]) {
echo '<div style="background-color:white; color-black;">';
echo 'Invalid Code '.$bcode.' '.$row2['barcode'];
echo '</div>';
} else {
if (!preg_match('/[^A-Za-z]+/', $name)) {
if (($_POST['y'] > 1950 && $_POST['y'] < 2005) && ($_POST['m'] > 0 && $_POST['m'] < 13) && ($_POST['d'] > 0 && $_POST['d'] < 32)) {
if (!preg_match('/[^0-9]+/', $phone) && strlen($phone) == 10) {
$query = "UPDATE appthing SET name=$name, email=$email, dob=$dob, insti=$insti, phone=$phone, school=$school, course=$course, address=$adress WHERE barcode=$bcode";
mysql_query($query) or die(mysql_error());
$to = $email;
$subject = "Tafconnect.com";
$message = "Hello! $name,<br />Registration Details <br /> Barcode : $bcode <br /> Contact : $phone <br /> DOB : $dob<br /><br />Thank you for registering your application";
$from = "admin@tafconnect.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo '<div style="background-color:white; color-black;">';
echo $name.', you have been registered! Please check back after 5th August for your interview schedule. Also check your mail for the registered details. Redirecting in 10 seconds';
echo '</div>';
echo '<meta http-equiv="refresh" content="10;URL=index.php">';
} else {
echo 'Invalid Phone Number';
}
} else {
echo 'Invalid DOB';
}
} else {
echo 'Invalid Name';
}
}
}
?>