Reputation: 85
I have been banging my head against the wall on this for about 2 hours now and I cannot figure out what im doing wrong. I am simply trying to update a MySQL database with new information. but when I click "Update Information" nothing is happening.
<div id="tabs-1">
<?php
//update main informaion
if(isset($_POST["toolnameupdate"])){
$companyname1 = "";
$toolname1 = "";
include_once("../php_includes/db_connect.php");
$companyname1 = $_POST['clientname'];
$toolname1 = $_POST['webtoolname'];
$sql = "UPDATE siteinformation SET clientname = $companyname1, srcname = $toolname1";
$query = mysqli_query($db_connect, $sql);
error_reporting(E_ALL);
header('Location: user.php');
}
?>
<form method="post" action="">
<fieldset>
<legend><strong>Main Title Information</strong></legend>
<div id="prompt">Client Company Name:</div><div id="answer"><input type="text" name="clientname" id="clientname" value="<? echo $companyname; ?>"/></div>
<div id="prompt">Web Tool Name:</div><div id="answer"><input type="text" name="webtoolname" id="webtoolname" value="<? echo $toolname; ?>"/></div>
<div id="prompt"><input type="submit" id="toolnameupdate" name="toolnameupdate" value="Update Information" /></div><div id="answer"> </div>
<div id="prompt"> </div><div id="answer"> </div>
</fieldset>
</form>
</div>
Can anyone see where it is missing information?
Thanks
Upvotes: 0
Views: 161
Reputation: 5057
I am not sure if this is the complete code. But form fields should be included in <form>
tags.
<form method="post" action="">
<fieldset>
<legend><strong>Main Title Information</strong></legend>
<div id="prompt">Client Company Name:</div><div id="answer"><input type="text" name="clientname" id="clientname" value="<? echo $companyname; ?>"/></div>
<div id="prompt">Web Tool Name:</div><div id="answer"><input type="text" name="webtoolname" id="webtoolname" value="<? echo $toolname; ?>"/></div>
<div id="prompt"><input type="submit" id="toolnameupdate" name="toolnameupdate" value="Update Information" /></div><div id="answer"> </div>
<div id="prompt"> </div><div id="answer"> </div>
</fieldset>
</form>
also the correct syntax is $_POST['..'], and not with parenthesis.
and also move error_reporting(E_ALL);
to the top of the file, otherwise it won't be too useful.
Upvotes: 5
Reputation: 32118
$_POST('clientname')
should be $_POST['clientname']
. And the same with the rest of the posts. Also read Aris's answer about the form tags.
After you revised your code you removed the quotes around the variables, they need to stay.
$sql = "UPDATE siteinformation SET clientname = '$companyname1', srcname = '$toolname1'";
Upvotes: 4