my code stock.com

Snippet options

Download: Download snippet as update-record.html.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

<!------UPDATE FORM---------->           
<?php
$stud_no="";
$fname="";
$lname="";
$course="";
$contact_no="";
$email="";

$csn="";
$ccn="";
$cemail="";

if (isset ($_POST['cancel'])){
	header("location:home.php#bot");}

if (isset ($_POST['submit'])){

$stud_no=clean($_POST['stud_no']);
$fname=clean($_POST['fname']);
$lname=clean($_POST['lname']);
$course=clean($_POST['course']);
$contact_no=clean($_POST['contact_no']);
$email=clean($_POST['email']);
			
//Data Validation
		$check_data = "SELECT * FROM stud_record WHERE stud_no='$stud_no' OR contact_no='$contact_no' OR email='$email'";
		
		$run = mysql_query($check_data);
		
		if (mysql_num_rows($run)>0){
			while ($rst = mysql_fetch_array($run)){
			//Is it username or email?
				if ($rst["stud_no"] == $_POST['stud_no']){
				$csn = "<td style = 'color:red;'>Student No: $stud_no is already in use.</td>";
				}
				if ($rst["contact_no"] == $_POST['contact_no']){
				$ccn = "<td style = 'color:red;'>Contact No: $contact_no is already in use.</td>";
				}
				if ($rst["email"] == $_POST['email']){
				$cemail = "<td style = 'color:red;'>Email $email is already in use.</td>";
				}
			}
		}
//Data Validation End			
		else{
			mysql_query("UPDATE stud_record SET stud_no='$stud_no',fname='$fname',lname='$lname',course='$course',contact_no='$contact_no',email='$email' WHERE id='$id'");
			header("location:home.php");}
}
?>

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.