Thanks coldwerturkey! It's working now thanks to your advice. You were able to tell me the problem area so I was able to effectively google for a solution from there. 🙂
I still have not figured out the proper formatting for the session variables, can you please provide an example or a link to an example for my learning?
Here is the script code that works for me now:
<?php
session_start();
if (!(isset($_SESSION['login']) && $_SESSION['login'] != '')) {
header ("Location: login.php");
}
$email = $_REQUEST['email'];
$website = $_REQUEST['website'];
$gender = $_REQUEST['gender'];
$age = $_REQUEST['age'];
$location = $_REQUEST['location'];
$favbirds = $_REQUEST['favbirds'];
$favplaces = $_REQUEST['favplaces'];
$favguide = $_REQUEST['favguide'];
$favequip = $_REQUEST['favequip'];
$favfest = $_REQUEST['favfest'];
$orgs = $_REQUEST['orgs'];
$sum = $_REQUEST['sum'];
$wint = $_REQUEST['wint'];
$username = $_SESSION['username'];
//Connect and select database
mysql_connect("192.168.254.000", "user", "pwd") or die(mysql_error());
mysql_select_db("tutorial") or die(mysql_error());
// Check matching of username
$result=mysql_query("select * from profiles where username = '$username'");
if(mysql_num_rows($result)!='0'){ // If match.
//update record
$query="UPDATE profiles SET email = '$email', website = '$website', gender = '$gender', age = '$age', location = '$location', favbirds = '$favbirds', favplaces = '$favplaces', favguide = '$favguide', favequip = '$favequip', favfest = '$favfest', orgs = '$orgs', sum = '$sum', wint = '$wint' WHERE username = '$username'";
mysql_query($query) or die(mysql_error());
header("Location: profile.php");
// $message="Profile updated successfully";
}else{ // If not match.
//insert data into table
$query="INSERT INTO profiles (email, website, gender, age, location, favbirds, favplaces, favguide, favequip, favfest, orgs, sum, wint, user) VALUES ('".$email."', '".$website."', '".$gender."', '".$age."', '".$location."', '".$favbirds."', '".$favplaces."', '".$favguide."', '".$favequip."', '".$favfest."', '".$orgs."', '".$sum."', '".$wint."', '$username')";
mysql_query($query) or die(mysql_error());
header("Location: profile.php");
// $message="Profile updated successfully";
}
?>
Also, thank you bradgrafelman, I will follow your advice for enabling error reporting.