Hey if anyone could help me out, that would be superb.
It is probably something simple but i am always getting undefined index messages.
This is the latest example.
Notice: Undefined index: savebtn in C:\xampp\htdocs\practice\editprofile.php on line 20
And this is the php.
if ($username){
require ("scripts/connect.php");
if ($_POST['savebtn']){
$forename = fixtext($_POST['forename']);
$surname = fixtext($_POST['surname']);
$housenona = fixtext($_POST['housenona']);
$addressline1 = fixtext($_POST['addressline1']);
$addressline2 = fixtext($_POST['addressline2']);
$city = fixtext($_POST['city']);
$postcode = fixtext($_POST['postcode']);
$email = fixtext($_POST['email']);
$password = fixtext($_POST['password']);
if ($forename && $surname && $email && $password){
if (strstr($email, "@") && strstr($email, ".") && (strlen($email) >= 6)){
$password = md5(md5($password));
$query = mysql_query("SELECT * FROM members WHERE id='$userid' AND password='$password'");
$numrows = mysql_num_rows($query);
if ($numrows == 1){
// set firstname
mysql_query("UPDATE members SET forename='$forename' WHERE id='$userid'");
// set lastname
mysql_query("UPDATE members SET surname='$surname' WHERE id='$userid'");
// set house no/name
mysql_query("UPDATE members SET housenona='$housenona' WHERE id='$userid'");
// set address line 1
mysql_query("UPDATE members SET addressline1='$addressline1' WHERE id='$userid'");
// set address line 2
mysql_query("UPDATE members SET addressline2='$addressline2' WHERE id='$userid'");
// set city
mysql_query("UPDATE members SET city='$city' WHERE id='$userid'");
// set post code
mysql_query("UPDATE members SET postcode='$postcode' WHERE id='$userid'");
// set email
mysql_query("UPDATE members SET email='$email' WHERE id='$userid'");
}
echo "Your information has been saved.";
}
else
echo "Your password was incorrect.";
}
else
echo "You did not provide a valid email.";
}
else
echo "You did not provied the required info.";
}
$query = mysql_query("SELECT * FROM members WHERE id='$userid'");
$numrows = mysql_num_rows($query);
if ($numrows == 1){
$row = mysql_fetch_assoc($query);
$id = $row['id'];
$forename = $row['forename'];
$surname = $row['surname'];
$housenona = $row ['housenona'];
$addressline1 = $row ['addressline1'];
$addressline2 = $row ['addressline2'];
$city = $row ['city'];
$postcode = $row ['postcode'];
$email = $row['email'];
$date = $row['date'];
}
else
echo "An error occured while connecting to the database.";
$infoform = "<form action='editprofile.php' method='post' enctype='multipart/form-data'>
<table cellspacing='5px'>
<tr>
<td></td>
<td><font color='red'>*</font> are required</td>
</tr>
<tr>
<td>First Name:</td>
<td><input type='text' name='forename' class='textbox' size='35' value='$forename'><font color='red'>*</font></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type='text' name='surname' class='textbox' size='35' value='$surname'><font color='red'>*</font></td>
</tr>
<tr>
<td>House no./name </td>
<td><input type='text' name='housenona' class='textbox' size='35' value='$housenona'><font color='red'>*</font></td>
</tr>
<tr>
<td>Address line 1</td>
<td><input type='text' name='addressline1' class='textbox' size='35' value='$addressline1'><font color='red'>*</font></td>
</tr>
<tr>
<td>Address line 2</td>
<td><input type='text' name='addressline2' class='textbox' size='35' value='$addressline2'><font color='red'>*</font></td>
</tr>
<tr>
<td>City</td>
<td><input type='text' name='city' class='textbox' size='35' value='$city'><font color='red'>*</font></td>
</tr>
<tr>
<td>Post Code</td>
<td><input type='text' name='postcode' class='textbox' size='35' value='$postcode'><font color='red'>*</font></td>
</tr>
<tr>
<td>Email:</td>
<td><input type='text' name='email' class='textbox' size='35' value='$email'><font color='red'>*</font></td>
</tr>
<tr>
<td>Current Password:</td>
<td><input type='password' name='password' class='textbox' size='35'></td>
</tr>
<tr>
<td></td>
<td><input type='submit' name='savebtn' value='Save Changes' class='button'></td>
</tr>
</table>
</form>";
echo "$infoform";
im having difficulty spotting the mistake. Could somebody help me solve this please.
Thanks