Using isset ($_POST[array[0]) not working - php

I need a little help with my code. If I substitute the second isset statement with the input name "submit2" everything works fine. However, if I replace the name with a string variable from an array, it doesn't work. I reviewed the ISSET manual and saw that I could use an array. There has to be something I did not take into consideration with my statement.
// First isset
if (isset($_POST['submit1']))
{
$firstname = trim($_POST['firstname']);
$lastname = trim($_POST['lastname']);
$sqlPlayersearch = "SELECT id, first_name, last_name, user_city, user_state, user_zip FROM wp_players WHERE first_name = '$firstname' AND last_name = '$lastname'";
$resultSearch = mysqli_query($link, $sqlPlayersearch);
}
$sqlPlyrSrch2 = "SELECT id FROM wp_players WHERE first_name = '$firstname' AND last_name = '$lastname'";
$PlyrSrch2 = mysqli_query($link, $sqlPlyrSrch2);
$plyr = array();
while ($rowplyr1 = mysqli_fetch_array($PlyrSrch2)) {
$plyr[] = $rowplyr1[0];
}
echo $plyr[0]; // "3"
var_dump($plyr[0]); // string(1) "3"
// Second isset
if (isset($_POST['$plyr[0]'])){
$plyrfound = "Yes, It is Working";
}
?>
<html>
<style type="text/css">
.tgd1 {border-collapse:collapse;border-spacing:0;border-color:#aabcfe;}
.tgd1 td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:#aabcfe;color:#669;background-color:#e8edff;}
.tgd1 th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:#aabcfe;color:#039;background-color:#b9c9fe;}
.tgd1 .tg-hmp3{background-color:#D2E4FC;text-align:left;vertical-align:top}
.tgd1 .tg-baqh{text-align:center;vertical-align:top;font-weight: 900}
.tgd1 .tg-mb3i{background-color:#D2E4FC;text-align:right;vertical-align:top}
.tgd1 .tg-lqy6{text-align:right;vertical-align:top}
.tgd1 .tg-0lax{text-align:left;vertical-align:top}
form {
display: block;
}
form {
margin-bottom: 20px;
}
</style>
<body>
<form method='POST'>
<label for="fname">First Name</label>
<input style="width: 200px;" type="text" id="fname" name="firstname" pattern="[A-Za-z]*">
<label for="lname">Last Name</label>
<input style="width: 200px;" type="text" id="lname" name="lastname" pattern="[A-Za-z]*">
<input type="submit" name="submit1" value="Find Player">
<table class="tgd1">
<tr>
<th class="tg-baqh" colspan="4">Players</th>
</tr>
<tr>
<td class="tg-baqh" style="text-align:center" width="5%">Player</td>
<td class="tg-baqh" style="text-align:center" width="8%">City</td>
<td class="tg-baqh" style="text-align:center" width="10%">State</td>
<td class="tg-baqh" style="text-align:center" width="10%">Select Player</td>
</tr>
<?php
while($row2 = mysqli_fetch_array($resultSearch))
{ $plyr_id = $row2[0];
var_dump($plyr_id);?>
<tr>
<td class="tg-0lax" style="text-align:center"><?php echo $row2[1]; ?> <?php echo $row2[2]; ?></td>
<td class="tg-lqy6" style="text-align:center"><?php echo $row2[3]; ?></td>
<td class="tg-lqy6" style="text-align:center"><?php echo $row2[4]; ?></td>
<td style="text-align:center"><input type="submit" value="Select" name="<?php echo $plyr_id;?>"></td>
</tr>
</form>
<?php
}
?>
</table>
<h1>Eric <?php echo $plyrfound; ?></h1>
</body>
</html>
When I inspect the code in a browser this is what I see:
I have also placed some echo statements and var_dumps to see where I might be making a mistake:
I am expecting to see "Eric Yes, It is working". However, it does not seem to be finding the second isset as a true statement when I hit the "select" button.
Thank you in advance for any assistance.

Related

php to mysql update query isnt running properly

UPDATE
I can now get it to update with actual values by having the coding on one page instead of 2 but it still wont update using the form, I have made it to only work on the landline for now until I can get it to work from the form.
Below is the new code without the html body which has some links to the php header;
$search = $_POST['search'];
$search2 = $_POST['search2'];
$results = mysqli_query($connection, "SELECT RecordReference, Dateofrecordcreation, Status, AgentName, ReturnFiledOn, InfoOnline, Surname, Forename, DateofBirth, UTR, NINO, Address, Postcode, AddressAffectiveFrom, Mobile, Landline, Email, Balance FROM `selfemployed` WHERE Surname LIKE '$search' AND Forename LIKE '$search2'");
while($row = mysqli_fetch_array($results))
{
$RecordReference = $row['RecordReference'];
$Dateofrecordcreation = $row['Dateofrecordcreation'];
$Status = $row['Status'];
$AgentName = $row['AgentName'];
$ReturnFiledOn = $row['ReturnFiledOn'];
$InfoOnline = $row['InfoOnline'];
$Surname = $row['Surname'];
$Forename = $row['Forename'];
$DateofBirth = $row['DateofBirth'];
$UTR = $row['UTR'];
$NINO = $row['NINO'];
$Address = $row['Address'];
$Postcode = $row['Postcode'];
$AddressAffectiveFrom = $row['AddressAffectiveFrom'];
$Mobile = $row['Mobile'];
$Landline = $row['Landline'];
$Email = $row['Email'];
$Balance = $row['Balance'];
}
if(isset($_POST['Update']))
$RecRef = $_POST['RecordReference'];
$Datereccr = $_POST['Dateofrecordcreation'];
$Sta = $POST['Status'];
$AgName = $_POST['AgentName'];
$Srnm = $_POST['Surname'];
$Frnm = $_POST['Forename'];
$DoB = $_POST['DateofBirth'];
$NatIn = $_POST['NINO'];
$Add = $_POST['Address'];
$Pstc = $_POST['Postcode'];
$AddAffFrm = $_POST['AddressAffectiveFrom'];
$UTaxR = $_POST['UTR'];
$Mob = $_POST['Mobile'];
$llffs = $_POST['Landline'];
$Eml = $_POST['Email'];
$RetFiled = $_POST['ReturnFiledOn'];
$Bal = $_POST['Balance'];
$Online = $_POST['InfoOnline'];
$id = $_POST['id'];
// Information to update
$sql_query = "UPDATE `selfemployed` SET `Landline` = '$llffs' WHERE RecordReference = '$RecordReference'";
// Update Qquery
mysqli_query($connection, $sql_query);
// Close our connection to the database
mysqli_close($connection);
?>
<!DOCTYPE html>
<html>
<style type="text/css">
<!--
Original post
I have been trying to create an update function for my database and have been stuck for days on this now so thought that I would ask for help. The code seems to run without issues and no errors are being reported but it isn't being updated.
The search/display code is below (this works ok except it doesnt show all the text when there is spaces in the data)
Here is the search and display code
require_once "config.php";
$search = $_POST['search'];
$search2 = $_POST['search2'];
$results = mysqli_query($connection, "SELECT RecordReference, Status, ReturnFiledOn, InfoOnline, Surname, Forename, DateofBirth, UTR, NINO, Address, Postcode, AddressAffectiveFrom, Mobile, Landline, Email, Balance FROM `selfemployed` WHERE Surname LIKE '$search' AND Forename LIKE '$search2'");
while($row = mysqli_fetch_array($results))
{
$RecordReference = $row['RecordReference'];
$Dateofrecordcreation = ['Dateofrecordcreation'];
$Status = $row['Status'];
$AgentName = $row['AgentName'];
$ReturnFiledOn = $row['ReturnFiledOn'];
$InfoOnline = $row['InfoOnline'];
$Surname = $row['Surname'];
$Forename = $row['Forename'];
$DateofBirth = $row['DateofBirth'];
$UTR = $row['UTR'];
$NINO = $row['NINO'];
$Address = $row['Address'];
$Postcode = $row['Postcode'];
$AddressAffectiveFrom = $row['AddressAffectiveFrom'];
$Mobile = $row['Mobile'];
$Landline = $row['Landline'];
$Email = $row['Email'];
$Balance = $row['Balance'];
}
// Close our connection to the database
mysqli_close($connection);
?>
<!DOCTYPE html>
<html>
<style type="text/css">
<!--
.style1 {color: #000000}
.style10 {color: #F4A5A4}
.style11 {color: #D3D3D3}
.style14 {color: #000000; font-size: 14px; }
.style15 {font-size: 14px}
.style16 {color: #D3D3D3; font-size: 14px; }
.style17 {color: #F4F2A4; font-size: 14px; }
.style3 {color: #000000; font-size: 18px; font-weight: bold; }
.style8 {color: #ABDEB2}
.style9 {color: #F4F2A4}
.style18 {
font-size: 24px;
font-weight: bold;
}
-->
</style>
<body>
<form action="updateselfemp.php" method="post">
<table width="850" border="0">
<tr>
<td width="420" valign="top" bgcolor="#F4A5A4"><table width="418" border="0">
<tr>
<td align="right">Reference<span class="style10">::</span></td>
<td><label>
<input name="RecordReference" type="text" id="RecordReference" value=<?php echo $RecordReference; ?> >
</label></td>
</tr>
<tr>
<td align="right">Date of Record Creation<span class="style10">::</span></td>
<td><label>
<input type="text" name="Dateofrecordcreation" id="Dateofrecordcreation" value=<?php echo $Dateofrecordcreation; ?> >
</label></td>
</tr>
<tr>
<td width="222" align="right"><span class="style15"><span class="style14">Company Status<span class="style10">:</span></span></span></td>
<td width="186"><select name="Status" id="Status">
<option selected><?php echo $Status; ?></option>
<option value="ACTIVE">ACTIVE</option>
<option value="CLOSED">CLOSED</option>
<option value="DORMANT">DORMANT</option>
<option value="PHOENIX">PHOENIX</option>
<option value="NO LONGER A CUSTOMER">NO LONGER A CUSTOMER</option>
</select></td>
</tr>
<tr>
<td align="right"><span class="style14">Agent Name<span class="style10">:</span>:</span></td>
<td><label>
<input name="AgentName" type="text" id="AgentName" value=<?php echo $AgentName; ?> >
</label></td>
</tr>
</table>
<span class="style1"></span></td>
<td width="420" valign="top" bgcolor="#F4F2A4"><p class="style3">Return Details</p>
<table width="418" border="0">
<tr>
<td width="263" align="right"><span class="style14">Date Return Filed</span><span class="style17">::</span></td>
<td width="145"><label>
<input name="DateReturnFiled" type="text" id="DateReturnFiled" value=<?php echo $ReturnFiledOn; ?> >
</label></td>
</tr>
<tr>
<td align="right"><span class="style15"><span class="style1">Is this information online?</span><span class="style9">::</span></span></td>
<td><label>
<select name="Online" id="Online">
<option><?php echo $InfoOnline; ?></option>
<option value="Yes">Yes</option>
<option value="No">No</option>
<option value="N/A">N/A</option>
</select>
</label></td>
</tr>
</table></td>
</tr>
<tr>
<td valign="top" bgcolor="#D3D3D3"><p class="style3">Details</p>
<table width="418" border="0">
<tr>
<td width="268" align="right"><span class="style14">Surname</span><span class="style16">::</span></td>
<td width="140"><label>
<input name="Surname" type="text" id="Surname" value=<?php echo $Surname; ?> >
</label></td>
</tr>
<tr>
<td align="right"><span class="style15"><span class="style1">Forename</span><span class="style11">::</span></span></td>
<td><label>
<input name="Forename" type="text" id="Forename" value=<?php echo $Forename; ?> >
</label></td>
</tr>
<tr>
<td align="right"><span class="style15"><span class="style1">Date of Birth</span><span class="style11">::</span></span></td>
<td><label>
<input name="DateofBirth" type="text" id="DateofBirth" value=<?php echo $DateofBirth; ?> >
</label></td>
</tr>
<tr>
<td align="right"><span class="style15"><span class="style1">UTR</span><span class="style11">::</span></span></td>
<td><label>
<input name="UTR" type="text" id="UTR" value=<?php echo $UTR; ?> >
</label></td>
</tr>
<tr>
<td align="right"><span class="style15"><span class="style1">National Insurance No</span><span class="style11"></span></span></td>
<td><label>
<input name="NINO" type="text" id="NINO" value=<?php echo $NINO; ?> >
</label></td>
</tr>
<tr>
<td align="right" valign="top"><span class="style15"><span class="style1">Address<span class="style11">::</span></span></span></td>
<td><label>
<textarea name="Address" id="Address" cols="25" value=<?php echo $Address; ?> rows="3"></textarea>
</label></td>
</tr>
<tr>
<td align="right" valign="top"><span class="style15"><span class="style1">Postcode</span><span class="style11">::</span></span></td>
<td><label>
<input name="Postcode" type="text" id="Postcode" value=<?php echo $Postcode; ?> >
</label></td>
</tr>
<tr>
<td align="right" valign="top"><span class="style15"><span class="style1">Address Affective From</span><span class="style11">::</span></span></td>
<td><input name="AddressAffectiveFrom" type="text" id="AddressAffectiveFrom" value=<?php echo $AddressAffectiveFrom; ?> ></td>
</tr>
<tr>
<td align="right" valign="top"><span class="style15"><span class="style1">Mobile</span><span class="style11">::</span></span></td>
<td><label>
<input name="Mobile" type="text" id="Mobile" value=<?php echo $Mobile; ?> >
</label></td>
</tr>
<tr>
<td align="right"><span class="style15"><span class="style1">Landline</span><span class="style11">::</span></span></td>
<td><label>
<input name="Landline" type="text" id="Landline" value="<?php echo $Landline; ?>" >
</label></td>
</tr>
<tr>
<td align="right"><span class="style15"><span class="style1">Email</span><span class="style11">::</span></span></td>
<td><label>
<input name="Email" type="text" id="Email" value=<?php echo $Email; ?> >
</label></td>
</tr>
<tr>
<td align="right"> </td>
<td><label></label></td>
</tr>
</table></td>
<td valign="top" bgcolor="#ABDEB2"><p class="style3">Balance</p>
<table width="418" border="0">
<tr>
<td width="261" align="right"><span class="style14">Outstanding Balance<span class="style8">::</span></span></td>
<td width="147"><label>
<input name="Balance" type="text" id="Balance" value=<?php echo $Balance; ?> >
</label></td>
</tr>
</table>
<p class="style1"> </p>
<p class="style1"> </p>
<p class="style1"> </p>
<p class="style1"> </p>
<p class="style1"> </p>
<p class="style1"> </p>
<p class="style1"> </p>
<p class="style1"> </p>
<p class="style1"> </p></td>
</tr>
<tr>
<td> </td>
<td align="right"><label>
<input type="submit" name="Submit" id="Update" value="Update Record">
<input type="hidden" name="id" value"<?php echo $RecordReference; ?>">
</label></td>
</tr>
</table>
</form>
<span class="style18">Current File Content</span>
<table>
<tr><td>Record Reference</td> <td><?php echo $RecordReference; ?></td></tr>
<tr><td>Date of Record Creation</td> <td><?php echo $Dateofrecordcreation; ?></td>
</tr>
<tr><td>Status</td> <td><?php echo $Status; ?></td></tr>
<tr><td>Agent Name</td> <td><?php echo $AgentName; ?></td></tr>
<tr><td>Return Filed On</td> <td><?php echo $ReturnFiledOn; ?></td></tr>
<tr><td>Surname</td> <td><?php echo $Surname; ?></td></tr>
<tr><td>Forename</td> <td><?php echo $Forename; ?></td></tr>
<tr><td>Date of Birth</td> <td><?php echo $DateofBirth; ?></td></tr>
<tr><td>UTR</td> <td><?php echo $UTR; ?></td>
</tr>
<tr><td>NINO</td> <td><?php echo $NINO; ?></td>
</tr>
<tr><td>Address</td> <td><?php echo $Address; ?></td></tr>
<tr><td>Postcode</td> <td><?php echo $Postcode; ?></td></tr>
<tr><td>AddressAffectiveFrom</td> <td><?php echo $AddressAffectiveFrom; ?></td></tr>
<tr><td>Mobile</td> <td><?php echo $Mobile; ?></td></tr>
<tr><td>Landline</td> <td><?php echo $Landline; ?></td></tr>
<tr><td>Email</td> <td><?php echo $Email; ?></td></tr>
<tr><td>Balance</td> <td><?php echo $Balance; ?></td></tr>
</table>
</body>
</html>
Here is the update code
<?php
$RecordReference = $_POST['RecordReference'];
$date = date('d/m/Y h:i:s', time());
$Status = $_POST['Status'];
$AgentName = $_POST['AgentName'];
$ReturnFiledOn = $_POST['DateReturnFiled'];
$InfoOnline = $_POST['Online'];
$Surname = $_POST['Surname'];
$Forename =$_POST['Forename'];
$DateofBirth = $_POST['DateofBirth'];
$UTR = $_POST['UTR'];
$NINO = $_POST['NINO'];
$Address = $_POST['Address'];
$Postcode = $_POST['Postcode'];
$AddressAffectiveFrom = $_POST['AddressAffectiveFrom'];
$Mobile = $_POST['Mobile'];
$Landline = $_POST['Landline'];
$Email = $_POST['Email'];
$Balance = $_POST['Balance'];
// Connect to the database
require_once "config.php";
// update data in mysqli database
$sql = ("UPDATE selfemployed SET RecordReference = '$RecordReference', Dateofrecordcreation = '$date', Status = '$Status', AgentName = '$AgentName', ReturnFiledOn = '$ReturnFiledOn', InfoOnline = '$InfoOnline', Surname = '$Surname', Forename = '$Forename', DateofBirth = '$DateofBirth', UTR = '$UTR', NINO = '$NINO', Address = '$Address', Postcode = '$Postcode', AddressAffectiveFrom = '$AddressAffectiveFrom', Mobile = '$Mobile', Landline = '$Landline', Email = '$Email', Balance = '$Balance' WHERE RecordReference = '$RecordReference'");
// Close our connection to the database
mysqli_close($connection);
?>
<script type="text/javascript">
window.history.go(-2);
</script>
Any help with this is very much appreciated as I am at a loss as to what is wrong.
// update data in mysqli database
$sql = "UPDATE selfemployed SET RecordReference = '$RecordReference', Dateofrecordcreation = '$date', Status = '$Status', AgentName = '$AgentName', ReturnFiledOn = '$ReturnFiledOn', InfoOnline = '$InfoOnline', Surname = '$Surname', Forename = '$Forename', DateofBirth = '$DateofBirth', UTR = '$UTR', NINO = '$NINO', Address = '$Address', Postcode = '$Postcode', AddressAffectiveFrom = '$AddressAffectiveFrom', Mobile = '$Mobile', Landline = '$Landline', Email = '$Email', Balance = '$Balance' WHERE RecordReference = '$RecordReference'";
//Send query
mysqli_query($connection, $sql);
// Close our connection to the database
mysqli_close($connection);
Please try to use Prepared Statements (mysqli stmts or PDOs) to avoid SQL Injections.
It turns out that when I put everything on one page all I needed to do was change the update button ID and Name from Update to update it then worked perfectly.
You never run update query please run update query like below
$sql = "UPDATE selfemployed SET RecordReference = '$RecordReference', Dateofrecordcreation = '$date', Status = '$Status', AgentName = '$AgentName', ReturnFiledOn = '$ReturnFiledOn', InfoOnline = '$InfoOnline', Surname = '$Surname', Forename = '$Forename', DateofBirth = '$DateofBirth', UTR = '$UTR', NINO = '$NINO', Address = '$Address', Postcode = '$Postcode', AddressAffectiveFrom = '$AddressAffectiveFrom', Mobile = '$Mobile', Landline = '$Landline', Email = '$Email', Balance = '$Balance' WHERE RecordReference = '$RecordReference'";
// Update Qquery
mysqli_query($connection, $sql);
// Close our connection to the database
mysqli_close($connection);

Why I can't keep my session when I register

customer_register.php
<?php
session_start();
?>
<form action="customer_register.php" method="post" enctype="multipart/form-data">
<?php
if (isset($_POST['c_name']) && isset($_POST['c_email']) && isset($_POST['c_usrname']) && isset($_POST['c_password']) && isset($_POST['c_country']) && isset($_POST['c_city']) && isset($_POST['c_contact']) && isset($_POST['c_address']) && isset($_FILES['c_image']['name'])) {
$c_ip_add = getIp();
$c_name = $_POST['c_name'];
$c_email = $_POST['c_email'];
$c_username = $_POST['c_usrname'];
$c_password = $_POST['c_password'];
$c_country = $_POST['c_country'];
$c_city = $_POST['c_city'];
$c_contact = $_POST['c_contact'];
$c_address = $_POST['c_address'];
$c_image = #$_FILES['c_image']['name'];
$c_tmp_name = #$_FILES['c_image']['tmp_name'];
$location = 'customer/customer_images/';
if (!empty($c_name) && !empty($c_email) && !empty($c_username) && !empty($c_password) && !empty($c_country) && !empty($c_city) && !empty($c_contact) && !empty($c_address) && !empty($c_image)) {
move_uploaded_file($c_tmp_name, $location.$c_image);
$select_user = "SELECT customers_username FROM customers WHERE customers_username = '$c_username'";
$run_select_user = mysqli_query($conn, $select_user);
if (mysqli_num_rows($run_select_user) == NULL) {
$insert_customer = "INSERT INTO customers(customers_ip, customers_name, customers_email, customers_username, customers_pass, customers_country, customers_city, customers_contact, customers_address, customers_image) VALUES ('$c_ip_add', '$c_name', '$c_email', '$c_username', '$c_password', '$c_country', '$c_city', '$c_contact', '$c_address', '$c_image')";
$run_insert_customer = mysqli_query($conn, $insert_customer);
$select_cart = "SELECT * FROM cart WHERE ip_add = '$c_ip_add'";
$run_select_cart = mysqli_query($conn, $select_cart);
$check_cart = mysqli_num_rows($run_select_cart);
if ($check_cart == 0) {
$_SESSION['customer_email'] = $c_email;
$_SESSION['username'] = $c_username;
echo '<script>alert("Account has been successfully created")</script>';
echo '<script>window.open("customer/my_account.php","_self")</script>';
} else {
$_SESSION['customer_email'] = $c_email;
$_SESSION['username'] = $c_username;
echo '<script>alert("Account has been successfully created")</script>';
echo '<script>window.open("checkout.php","_self")</script>';
}
} else {
echo "<div align='center' style='color:white; font-size:20px; padding:20px 0px;'><b>The Username already exists. Please try another username.</b></div>";
}
} else {
echo "<div align='center' style='color:white; font-size:20px; padding:20px 0px;'><b>All Fileds are required</b></div>";
}
}
?>
<table align="center" width="750">
<thead>
<tr align="center">
<th colspan="3"><h1>Create an Account</h1></th>
</tr>
</thead>
<tbody>
<tr>
<td id="label" align="right">Name:</td>
<td><input type="text" name="c_name" size="40" required></td>
</tr>
<tr>
<td id="label" align="right">Email:</td>
<td><input type="text" name="c_email" size="40" required></td>
</tr>
<tr>
<td id="label" align="right">Username:</td>
<td><input type="text" name="c_usrname" size="40" required></td>
</tr>
<tr>
<td id="label" align="right">Password:</td>
<td><input type="password" name="c_password" size="40" required></td>
</tr>
<tr>
<td id="label" align="right">Image:</td>
<td><input type="file" name="c_image" required></td>
</tr>
<tr>
<td id="label" align="right">Country:</td>
<td>
<select name="c_country">
<option size="50">Select Country</option>
<?php countries(); ?>
</select>
</td>
</tr>
<tr>
<td id="label" align="right">City:</td>
<td><input type="text" name="c_city" size="40" required></td>
</tr>
<tr>
<td id="label" align="right">Contact:</td>
<td><input type="text" name="c_contact" size="40" required></td>
</tr>
<tr>
<td id="label" align="right">Address:</td>
<td><input type="text" name="c_address" size="40" required></td>
</tr>
<tr align="center">
<td colspan="3"><input type="submit" name="register" value="Create Account"></td>
</tr>
</tbody>
</table>
</form>
customer_login.php
<?php
session_start();
?>
<form method="post" action="">
<table width="500" align="center" bgcolor="skyblue">
<thead>
<tr align="center">
<th colspan="4"><h2>Login or Register to Buy!</h2></th>
</tr>
</thead>
<tbody>
<tr>
<td align="right"><b>Email:</b></td>
<td><input type="text" name="email" placeholder="Enter Email"></td>
</tr>
<tr>
<td align="right"><b>Password:</b></td>
<td><input type="password" name="pass" placeholder="Enter Password"></td>
</tr>
<tr align="center">
<td colspan="4">Forgot Password?</td>
</tr>
<tr align="center">
<td colspan="3"><input type="submit" name="login" value="Login"></td>
</tr>
</tbody>
</table>
<h2 style="float:right; padding:10px;">New? Register Here</h2>
</form>
<?php
if (isset($_POST['email']) && isset($_POST['pass'])) {
$email = $_POST['email'];
$pass = $_POST['pass'];
if (!empty($email) && !empty($pass)) {
$select_id = "SELECT * FROM customers WHERE customers_email = '$email' AND customers_pass = '$pass'";
$run_select_id = mysqli_query($conn, $select_id);
foreach ($run_select_id as $details) {
$usrname = $details['customers_username'];
$id = $details['customers_id'];
}
$num_run_select = mysqli_num_rows($run_select_id);
if ($num_run_select == NULL) {
echo '<script>alert("Invalid : Email/Password combination")</script>';
exit();
}
$c_ip_add = getIp();
$select_cart = "SELECT * FROM cart WHERE ip_add = '$c_ip_add'";
$run_select_cart = mysqli_query($conn, $select_cart);
$check_cart = mysqli_num_rows($run_select_cart);
if ($num_run_select > 0 AND $check_cart == 0) {
$_SESSION['customer_email'] = $email;
$_SESSION['username'] = $usrname;
$_SESSION['id'] = $id;
echo "<script>alert('You Have Logged In Succesfully')</script>";
echo "<script>window.open('customer/my_account.php','_self')</script>";
exit();
} else {
$_SESSION['customer_email'] = $email;
$_SESSION['username'] = $usrname;
$_SESSION['id'] = $id;
echo "<script>alert('You Have Logged In Succesfully')</script>";
echo "<script>window.open('checkout.php','_self')</script>";
}
} else {
echo 'Please enter valid email ID';
}
}
?>
my_account.php
<?php
session_start();
?>
<ul id="categories">
<?php
$location = 'customer_images/';
$usr_email = $_SESSION['customer_email'];
$user_name = #$_SESSION['username'];
$usr_id = $_SESSION['id'];
$select_image = "SELECT * FROM customers WHERE customers_id = '$usr_id'";
$run_image = mysqli_query($conn,$select_image);
foreach ($run_image as $select_all_data) {
$id = $select_all_data['customers_id'];
$name = $select_all_data['customers_name'];
$username = $select_all_data['customers_username'];
$email = $select_all_data['customers_email'];
$country = $select_all_data['customers_country'];
$city = $select_all_data['customers_city'];
$contact = $select_all_data['customers_contact'];
$address = $select_all_data['customers_address'];
$image = $select_all_data['customers_image'];
echo "<li style=''><img src='$location$image' height='150' width='174' style='text-align:center; border:3px solid black; padding:4px; border-radius: 109px;'></li>";
}
?>
<li>My Orders</li>
<li>Edit Account</li>
<li>Change Password</li>
<li>Delete Account</li>
<li>Logout</li>
</ul>
</div>
<div class="content_area2">
<?php cart(); ?>
<div id="my_account_menu">
<span>
<?php
if (isset($_SESSION['customer_email'])) {
echo "Welcome <i style='color:orange;'>" . $_SESSION['username']. ' </i>';
}
?>
<?php
if (!isset($_SESSION['customer_email'])) {
echo "<a href='../checkout.php' style='color:white;'>Login</a>";
} else {
echo "<a href='../logout.php' style='color:orange;'>Logout</a>";
}
?>
</span>
</div>
<?php getIp(); ?>
<div id="products_box">
<?php
if (!isset($_GET['my_orders']) && !isset($_GET['edit_account']) && !isset($_GET['change_pass']) && !isset($_GET['delete_account'])) {
?>
<div style="text-align:center;">
<table>
<tbody>
<tr>
<td id="label">Name : </td>
<td id="detail"><?php echo #$name; ?></td>
</tr>
<tr>
<td id="label">Username (Display Name) : </td>
<td id="detail"><?php echo #$username; ?></td>
</tr>
<tr>
<td id="label">Email : </td>
<td id="detail"><?php echo #$email; ?></td>
</tr>
<tr>
<td id="label">City : </td>
<td id="detail"><?php echo #$city; ?></td>
</tr>
<tr>
<td id="label">Contact : </td>
<td id="detail"><?php echo #$contact; ?></td>
</tr>
<tr>
<td id="label">Address : </td>
<td id="detail"><?php echo #$address; ?></td>
</tr>
</tbody>
</table>
</div>
<div style="padding:20px;"><b>You can see your orders by clicking this link</b></div>
<?php
}
?>
The problem is when I login it is working fine but when I register the user it gives the error undefined
$usr_id = $_SESSION['id'];
in my_account.php and all the information about the user is not displayed
I HAVE STARTED THE SESSION
I think you forget to call session_start before to do anything, even when there is no existing session.
<?php
session_start()
// your code...
You may want to look how it works with the basic example from the session_start function
As stated within the PHP session_start documentation:
To use cookie-based sessions, session_start() must be called before outputing anything to the browser.
So you may want to include this call after PHP opening tag <?php as I wrote above
You have to initiate the session by using session_start() on every page where you want to use the session. And this is missing on my_account.php
Ex:
<?php
session_start();
// your code
nowhere in your customer_register.php file do you actually set $_SESSION['id'].
in addition to this:
there are no form tags around your register form, so its hard to see how any data is getting into the script anyway.
your'e also silencing (#) errors. If this is a learning task, which from your comments I assume it is, thats a very counterproductive thing to do.
As you only set $_SESSION['id'] in the login handing script, its not going to be available across pages unless they go through that form. Its hard to tell from your code what your'e intended user journey is, but as it stands at the moment it looks like your'e expecting them to register, then be able to see the account page as a logged in user.
Just set $_SESSION['id'] in the register script, or dispense with it entirely and use the username (seeing as you validate it as unique anyway).
Also, your'e query in the my_account.php is looking for a column customer_id which (as far as I can see) you dont actually set in the insert statement.
This is the trouble with programming, it only does what you tell it to do.

php: session not working while running live on server

I am working on a project of PHP. I have a strange error. My PHP project is working well on local server (WAMP server). But after hosting it on live server, it is not working.
Problem: Session variable created on Login.php page is not passing value on Report.php page. The code is as below:
Login.php
<?php
$con=mysql_connect("mysql51****************","username","password")or die(mysql_error());
$select_db=mysql_select_db("database_name",$con);
$error="";
if(isset($_POST['submit']))
{
$userid=mysql_real_escape_string($_POST['username']);
$password=mysql_real_escape_string($_POST['password']);
$sql="SELECT * FROM user_details WHERE user_name='{$userid}' AND password='{$password}' ";
$result = mysql_query($sql);
if(mysql_num_rows($result) <= 0)
{
$error="Invalid UserId or Password.";
}
else
{
//session_set_cookie_params(60*60*60, '/', '.abcxyz.com');
ini_set('session.cookie_domain','.abcxyz.com');
session_start();
//$userid=mysql_real_escape_string($_POST['abc']);
//echo($userid);
$_SESSION['user']=$userid;
$_SESSION['userid']="true";
//echo $_SESSION['userid'];
$error="Successfully Login";
//header("Location: admin.php?page=report");
/*echo '<script type="text/javascript">alert("header is not working.' . $_SESSION['user'] . '");</script>';
*/ ?>
<script type="text/javascript">
/*alert("Please select a Source And Destination Country"); */
window.location.href='admin.php?page=report';
</script>
<?php
}
}
?>
<br />
<h1 style="text-align:center">Login</h1>
<form class="login" action="login.php" method="post" name="form1" id="form1">
<p>Username:</p>
<input class="login-input" type="text" name="username" value=""/>
<p> Password : </p>
<input class="login-input" type="password" name="password" value=""/>
<p>
<p style="color:#F00; font-size:12px; font-weight:100"><?php echo htmlentities($error); ?> </p>
<input class="login-submit" type="submit" name="submit" value="Login"/>
</form>
Report.php
<?php
include("connections/Connections.php");
/*$con=mysql_connect("localhost","admin","")or die(mysql_error());
$select_db=mysql_select_db("test",$con);*/
/*session_start();
if(session_is_registered('test'))
{
echo"registered";
}
else
{
header("Location: login.php");
}*/
//$user=$_SESSION['userid'];
$user=$_SESSION['userid'];
echo '<script type="text/javascript">alert("header is not working.' .$user . '");</script>';
if($user=="true")
{
//echo " Logining Successfully.";
}
else
{
?>
<script type="text/javascript">
//alert("Please select a Source And Destination Country");
window.location.href='login.php';
</script>
<?php
//header("Location: login.php");
}
?>
<?php
/*session_start();
$user=$_SESSION['userid'];
echo($user);
if($user=="Admin")
{
echo " Logining Successfully.";*/
$sql="SELECT * FROM register ";
if(isset($_POST['btnfilter']))
{
$search_term=mysql_real_escape_string($_POST['search_text']);
$answer = $_POST['filter'];
if ($answer == "ID") {
$sql .="WHERE id= '{$search_term}' ";
}
elseif ($answer == "Name") {
$sql .="WHERE fullname Like '%{$search_term}%'";
}
elseif ($answer == "DOB") {
$sql .="WHERE dob Like '%{$search_term}%' ";
}
elseif ($answer == "Occupation") {
$sql .="WHERE occupation Like '%{$search_term}%' ";
}
else
{
echo("Pealse Enter a valid value");
}
}
elseif(isset($_POST['btnrmfilter']))
{
$sql="SELECT * FROM register";
}
$query=mysql_query($sql) or die(mysql_errno());
//}
/*else
{
header('Location: /login.php');
}*/
?>
<style type="text/css">
table
{
font-size:12px;border-bottom:1px solid #ccc;
border-left:1px solid #ccc}
td
{
padding:5px 3px;
border-top:1px solid #ccc;
border-right:1px solid #ccc}
</style>
<div class="content">
<h1>Data Reading From database.</h1>
<form id="search_form" method="post" action="">
<div class="radio">
<input type="radio" name="filter" value="ID" />ID
<input type="radio" name="filter" value="Name" />Name
<input type="radio" name="filter" value="DOB"/>DOB
<input type="radio" name="filter" value="Occupation"/>Occupation<br />
</div>
<div class="input" >
<input type="text" name="search_text" value=""/>
<input type="submit" value="FilterData" name="btnfilter" />
<input type="submit" value="RemoveFilter" name="btnrmfilter" />
</div>
</form>
<table border="0" cellpadding="0" cellspacing="0">
<colgroup>
<col width="2%" style="color:#f60" valign="middle" align="center" >
<col width="12%" >
<col width="8%" >
<col width="5%" align="center" >
<col width="10%" >
</colgroup>
<tr style="background:#eee; height:30px;">
<td>ID</td>
<td>Name</td>
<td>DOB</td>
<td>Nationality</td>
<td>Mobile No</td>
<td>Phone No</td>
<td>Email</td>
<td>Education</td>
<td>Occupation</td>
<td>Comment</td>
<td >Noofexp</td>
</tr>
<?php while($row = mysql_fetch_array($query)) { ?>
<tr>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['fullname']; ?></td>
<td><?php echo $row['dob']; ?></td>
<td><?php echo $row['nationality']; ?></td>
<td><?php echo $row['mobno']; ?></td>
<td><?php echo $row['phno']; ?></td>
<td><?php echo $row['email']; ?></td>
<td><?php echo $row['education']; ?></td>
<td><?php echo $row['occupation']; ?></td>
<td><?php echo $row['comment']; ?></td>
<td><?php echo $row['noofexp']; ?></td>
</tr>
<?php } ?>
</table>
<h2> </h2>
<h3>Thanks for view.</h3>
<!-- end .content --></div>
<div class="footer">
<p>Footer</p>
<!-- end .footer --></div>
<!-- end .container --></div>
</body>
</html>
Edit:
As the answers suggested, i edited as below:
Login.php:
<?php
session_start();
$con=mysql_connect("mysql51*************","username","password")or die(mysql_error());...
...
Report.php:
<?php
session_start();
include("connections/Connections.php");...
...
But still i am not getting the session variable value in Report.php.
session_start(); should be placed on top of the both pages.
have you checked your phpinfo() ?
make shure you have
Session Support - enabled
You must add session_start(); in your report.php page
If it runs on your WAMP successfully, It is very possible that the problem is not from your code but from your hosting company.
Something like this happened to me before.
Just call you hosting company and tell them to enable session on their server for you and they will it for you.
and always start session first before any script just as you did above.
session_start();
Enjoy
Go try adding this on your code:
if(!$con)
{
die('Could not connect:'. mysql_error());
}
and see what the error is.
very easy solve to this problem copy this code
error_reporting(0);
session_start();
Note: give space from left side of session_start(); if you want understand about this watch this video

inserting data to table from frontend wordpress

I'm trying to insert data to custom table from frontend as well as backend in wordpress.
Below is my code, its working if i insert the data from backend but its giving me Error 404 if i try to insert from frontend.
<?php
/*
Plugin Name: Custom Form
Description: Custom Plugin
Author: Bijay Luitel
*/
// Create the table if not exixts
?>
<style>
p {
display:block;
}
h3 {
height:20px;
padding:10px 5px;
}
</style>
<?php
//Short Codes
add_shortcode('form_bands','form_bands');
function form_bands(){
global $wpdb;
$this_page = $_SERVER['REQUEST_URI'];
$query1 = "SELECT * FROM grade";
$result1 = $wpdb->get_results($query1);
$query2 = "SELECT * FROM branch";
$result2 = $wpdb->get_results($query2);
if($_POST['action']==1 && $_POST['name'] != '' ){
$page_one_table = 'band';
$name =$_POST['name'];
$mailingAddress = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$email = $_POST['email'];
$url = $_POST['url'];
$telephone = $_POST['telephone'];
$gradeId = $_POST['grade'];
$branchId = $_POST['branch'];
$insertMe="INSERT INTO band ('Name', 'MailingAddress', 'City', 'State', 'Zip', 'Email', 'URL', 'Telephone', 'GradeID', 'BranchID') VALUES('$name', '$mailingAddress', '$city', '$state', '$zip', '$email', '$url', '$telephone', '$gradeId', '$branchId')";
$insert_page_one = $wpdb->query($insertMe);
//$insert_page_one = $wpdb->insert($page_one_table, $page_one_inputs);
$form_id = $wpdb->insert_id;
if($insert_page_one)
{
echo '<div id="successMsg" class="updated below-h2"><p>Operation Successful</p></div>';
}
else{
echo '<div id="successMsg" class="updated below-h2"><p>Error ! Recheck and tryagain.</p></div>';
}
}
elseif ($_POST['action']==1 && $_POST['name'] == ''){
echo '<div id="successMsg" class="updated below-h2"><p>Error ! Recheck and tryagain.</p></div>';
}
?>
<h2>Bands</h2>
<div class="postbox">
<form action="" method="post">
<div class="inside">
<table class="form-table">
<tr>
<th>Name :</th>
<td><input type="text" name="name" /></td>
</tr>
<tr>
<th>Address :</th>
<td><input type="text" name="address" /></td>
</tr>
<tr>
<th>City :</th>
<td><input type="text" name="city" /></td>
</tr>
<tr>
<th>State :</th>
<td><input type="text" name="state" /></td>
</tr>
<tr>
<th>Zip :</th>
<td><input type="text" name="zip" /></td>
</tr>
<tr>
<th>Telephone :</th>
<td><input type="text" name="telephone" /></td>
</tr>
<tr>
<th>Email :</th>
<td><input type="text" name="email" /></td>
</tr>
<tr>
<th>Url :</th>
<td><input type="text" name="url" /></td>
</tr>
<tr>
<th>Grade :</th>
<td><select name="grade">
<?php foreach($result1 as $row){
$value = $row->GradeID;
echo '<option value="'.$value.'">';
echo $row->Grade;
echo "</option>";
}?>
</select></td>
</tr>
<tr>
<th>Branch :</th>
<td><select name="branch">
<?php foreach($result2 as $row){
$value = $row->BranchID;
echo '<option value="'.$value.'">';
echo $row->Name;
echo "</option>";
}?>
</select></td>
</tr>
</table>
<p class="submit">
<input type="submit" name="add_form" class="button-primary" value="Submit" />
</p>
<input type="hidden" name="action" value="1" />
</form>
</div>
</div>
<?php
}
function myForm ()
{
add_menu_page('Forms', 'Forms', '','forms', '');
add_submenu_page("forms", "Bands", "Bands", 0, "Bands", "form_bands");
}
add_action('admin_menu','myForm');
How can i solve this problem? Please Help me
I expect the issue you're having relates to your use of a "reserved" post variable name, of 'name'.
The WordPress Codex page for Register_Taxonomy() contains the list of "reserved terms".
Further, your action attribute on your form tag is missing your URL. That's handled OK in current browsers, but may cause unexpected behavior in some older browsers, and isn't guaranteed to work in future.
Better practice is to remove this attribute altogether, if you're not going to use it, because the spec strongly discourages authors from leaving it empty:
The action and formaction content attributes, if specified, must have a value that is a valid non-empty URL potentially surrounded by spaces.
(This info re the action attribute thanks to #mercator with this answer )

You have an error in your SQL syntax;

G'Day
I have a php page that I want to edit an entry but for the life of me I can not figure out why it is coming up with this erro.
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= po_postcode = '4060', email ='-', phone = '732997688', fax = '' WHERE id='1'' at line 1
HELP I am desperate and going insane. (Similar Code works on another page but not this one)....
Can someone PLEASE HELP.
{
<?php
/*
EDIT.PHP
Allows user to edit specific entry in database
*/
// creates the edit record form
// since this form is used multiple times in this file, I have made it a function that is easily reusable
function renderForm($id, $name, $po_street, $po_suburb, $po_state, $po_postcode, $email, $phone, $fax, $error)
{
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Edit Record</title>
</head>
<body>
<?php
// if there are any errors, display them
if ($error != '')
{
echo '<div style="padding:4px; border:1px solid red; color:red;">'.$error.'</div>';
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Edit Record</title>
</head>
<body>
<table width="347" border="0" align="center">
<tr valign="baseline">
<td align="right" nowrap="nowrap"><p align="center"><img src="hartwell_banner.JPG" width="624" height="134" /></p>
</tr>
</table>
<table align="center">
<tr valign="baseline">
<td width="290" align="right" nowrap="nowrap"><div align="left"><h2 align="left"><p align="left">Enter a New Contact</p></h2></div></td>
<td width="290" align="center" nowrap="nowrap"><div align="left"><h2 align="center"><p align="center">Return to Index</p>
</h2>
</div></td>
</tr>
</table>
<form action="" method="post">
<input type="hidden" name="id" value="<?php echo $id; ?>"/>
<table align="center">
<tr valign="baseline">
<td width="98" align="right" nowrap="nowrap"><div align="left">ID:</div></td>
<td width="329"><input type="text" name="id" value="<?php echo $id; ?>" size="40" readonly = "readonly" /> * </td>
</tr>
<tr valign="baseline">
<td width="98" align="right" nowrap="nowrap"><div align="left">Name:</div></td>
<td width="329"><input type="text" name="name" value="<?php echo $name; ?>" size="40" /> * </td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><div align="left">Postal Street </div></td>
<td><input type="text" name="po_street" value="<?php echo $po_street; ?>" size="40" /> * </td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><div align="left">Postal Suburb</div></td>
<td><Input type ="text" name="po_suburb" value="<?php echo $po_suburb; ?> " size="30" maxlength="50" >*</td>
<tr valign="baseline">
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><div align="left">State</div></td>
<td><Input type ="text" name="po_state" value="<?php echo $po_state; ?>" size="5" maxlength="3" /> * </td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><div align="left">Postal Postcode</div></td>
<td><Input type ="text" name="po_postcode" value="<?php echo $po_postcode; ?>" size="5" maxlength="4"/> * </td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><div align="left">Email:</div></td>
<td><input type="text" name="email" value="<?php echo $email; ?>" size="40" /> * </td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><div align="left">Phone:</div></td>
<td><input name="phone" type="text" value="<?php echo $phone; ?>" size="12" maxlength="10" /> * </td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><div align="left">Fax:</div></td>
<td><input name="fax" type="text" value="<?php echo $fax; ?>" size="12" maxlength="10" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td> <input type="submit" name="submit" value="Submit"> * Denotes Required Field<?php
// if there are any errors, display them
if ($error != '')
{
echo '<div style="padding:4px; border:1px solid red; color:red;">'.$error.'</div>';
}
?> </td>
</tr>
<tr valign="baseline">
<td colspan="2" align="right" nowrap="nowrap"><div align="center"><img src="hartwell_costs.JPG" alt="" width="340" height="147" /></div></td>
</tr>
</table>
</form>
</body>
</html>
<?php
}
// check if the form has been submitted. If it has, process the form and save it to the database
if (isset($_POST['submit']))
{
// confirm that the 'id' value is a valid integer before getting the form data
if (isset($_POST['id']))
{
// get form data, making sure it is valid
$id = mysql_real_escape_string(htmlspecialchars($_POST['id']));
$name = mysql_real_escape_string(htmlspecialchars($_POST['name']));
$po_street = mysql_real_escape_string(htmlspecialchars($_POST['po_street']));
$po_suburb = mysql_real_escape_string(htmlspecialchars($_POST['po_suburb']));
$po_state = mysql_real_escape_string(htmlspecialchars($_POST['po_state']));
$po_postcode = mysql_real_escape_string(htmlspecialchars($_POST['po_postcode']));
$email = mysql_real_escape_string(htmlspecialchars($_POST['email']));
$phone = mysql_real_escape_string(htmlspecialchars($_POST['phone']));
// check that firstname/lastname fields are both filled in
if ($id == '' || $name == '' || $po_street == '' || $po_suburb == ''|| $po_state == '' || $po_postcode == ''|| $email == '' || $phone == '')
{
// generate error message
$error = 'ERROR: Please fill in all required fields!';
//error, display form
renderForm($id, $name, $po_street, $po_suburb, $po_state, $po_postcode, $email, $phone, $fax, $error);
}
else
{
// save the data to the database
mysql_select_db($database_hartwell, $hartwell);
mysql_query("UPDATE contact SET id= '$id', name='$name', po_street ='$po_street', po_suburb = '$po_suburb', po_state = '$po_state', = po_postcode = '$po_postcode', email ='$email', phone = '$phone', fax = '$fax' WHERE id='$id'")
or die(mysql_error());
// once saved, redirect back to the view page
header("Location: view.php");
}
}
else
{
//if the 'id' isn't valid, display an error
echo 'ID Not Valid!';
}
}
else
// if the form hasn't been submitted, get the data from the db and display the form
{
// get the 'id' value from the URL (if it exists), making sure that it is valid (checing that it is numeric/larger than 0)
if (isset($_GET['id']) && is_numeric($_GET['id']) && $_GET['id'] > 0)
{
// query db
$id = $_GET['id'];
mysql_select_db($database_hartwell, $hartwell);
$result = mysql_query("SELECT * FROM contact WHERE id=$id")
or die(mysql_error());
$row = mysql_fetch_array($result);
// check that the 'id' matches up with a row in the databse
if($row)
{
// get data from db
$id = $row['id'];
$name = $row['name'];
$po_street = $row['po_street'];
$po_suburb = $row['po_suburb'];
$po_state = $row['po_state'];
$po_postcode = $row['po_postcode'];
$email = $row['email'];
$phone = $row['phone'];
$fax = $row['fax'];
// show form
renderForm($id, $name, $po_street, $po_suburb, $po_state, $po_postcode, $email, $phone, $fax,'');
}
else
// if no match, display result
{
echo "No results!";
}
}
else
// if the 'id' in the URL isn't valid, or if there is no 'id' value, display an error
{
echo 'No ID Value!';
}
}
?>
The error is right there in your query, just like the error message says:
, = po_postcode = '$po_postcode',
^
|
+ this doesn't belong here
remove the equal sign here:
'$po_state', = po_postcode
mysql_query("UPDATE contact SET id= '$id', name='$name', po_street ='$po_street', po_suburb = '$po_suburb', po_state = '$po_state', po_postcode = '$po_postcode', email ='$email', phone = '$phone', fax = '$fax' WHERE id='$id'")
So the problem is here = po_postcode = '$po_postcode',

Categories