I am trying to add address fields into my registration form but whenever I submit the register Im having error with my address line here is what the error message say
Notice: Undefined index: address in C:\xampp\htdocs\profile\register\index.php on line 9
This is the php code:
<?php
session_start();
if(isset($_REQUEST['sub']) && isset($_POST['gender'])){
$lname = strtoupper(trim(strip_tags($_POST['lname'])));
$fname = strtoupper(trim(strip_tags($_POST['fname'])));
$mname = strtoupper(trim(strip_tags($_POST['mname'])));
$cours = strtoupper(trim(strip_tags($_POST['gender'])));
$address =strtoupper(trim(strip_tags($_POST['address'])));
$email = strip_tags($_POST['email']);
$pass1 = strip_tags($_POST['pass']);
if(empty($lname) || empty($fname) || empty($mname) || empty($email) || empty($address)
|| empty($pass1) || empty($cours) || $_POST['gender'] == 'none' ){
$mess = "<font color='red'><i>Field(s) Required!</i></font>";
}
else if(!ctype_alpha($lname)||!ctype_alpha($fname)|| !ctype_alpha($mname)){
$mess = "<font color='red'><i>Incorrect Name Format!</i></font>";
}
else if(!preg_match('/^[a-zA-z0-9_.]*@[a-zA-z0-9.]*$/', $email)){
$mess = "<font color='red'><i>Incorrect Email Format!</i></font>";
}
else{
$host = "localhost";
$user = "root";
$pass = "";
$data = "school";
$connect = mysql_connect($host, $user, $pass);
mysql_select_db($data, $connect);
if(mysql_query("INSERT INTO studentinfo(`userid`, `lastname`, `firstname`, `middlename`, `email`, `address`, `password`, `gender`)
VALUES (null,'$lname','$fname','$mname','$email',`$address`,'$pass1','$cours') ")){
$mess = "Account Added to Database!";
}
else{
$mess = "<font color='red'><i>Data Already Exist!</i></font>";
}
}
}
if(isset($_REQUEST['back'])){
header( 'Location: ../' );
}
if(!empty($_SESSION['logon'])){
header( 'Location: ../' );
}
?>