I built something for my office, PHP CODE
when I built it over my APACHE it worked fine, when I uploaded it to the server I'm getting the POD or MYSQLI errors, I fixed it (by using "error_reporting(E_ALL ^ E_DEPRECATED);" on the top, and it worked)
the only problem that I'm having now is that I can't update the database as I did on my APACHE, it just doesn't update. it give me the OK message but it doesn't update anything.
this is my code:
<?php
mysqli_connect('localhost','USERNAME','PASSWORD','TABLE');
if(isset($_POST["register"]))
{
$status=$_POST["status"];
mysqli_query("update login set status='$status' WHERE username='".$_SESSION['name_of_user']."'");
echo "<font face=tahoma size=3 color=red>Thank you, the office has been updated.</br></font>";
}
mysqli_close($con);
?>
<form method="post" action=" ">
<font face=tahoma size=3><b>
<label >Update Status:</label>
</br>
<select name="status">
<option value="In a Meeting">In a Meeting</option>
<option value="Waiting for a Meeting">Waiting for Meeting</option>
<option value="In a Referral">In a Referral</option>
<option value="Off Work">Off Work</option>
</select>
<button type="submit" class="btn btn-info" name="register" >Send</button>
</br>
</font>
</form>
Seems like you forgot to start the session in your page
<?php
session_start();
and your mysqli_connect('localhost','USERNAME','PASSWORD','TABLE');
should be mysqli_connect('localhost','USERNAME','PASSWORD','your_database_name');
$con =mysqli_connect('localhost','USERNAME','PASSWORD','your_database_name');
mysqli_query($con,"update login set status='$status' WHERE username='".$_SESSION['name_of_user']."'");
mysqli_query
appears to be missing the $con
variable which should be the first parameter. $con isn't being set anywhere and should come from mysqli_connect
See the docs for connect and query
<?php
$con = mysqli_connect('localhost','USERNAME','PASSWORD','TABLE');
if(isset($_POST["register"]))
{
$status=$_POST["status"];
mysqli_query($con, "update login set status='$status' WHERE username='".$_SESSION['name_of_user']."'");
echo "<font face=tahoma size=3 color=red>Thank you, the office has been updated.</br></font>";
}
mysqli_close($con);
?>
you forget to start the session
session_start()
you have to declare $con
variable before use it
use this query
mysqli_query($con,"update login set status='".$status."' WHERE username='".$_SESSION['name_of_user']."'");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.