在下面的代码中,除了单击提交按钮时,一切都有效,
请告诉我什么是错的,连接和一切都很好(它包含在Header.php文件中)并在其他页面上提交表单工作,但是这个似乎什么都不做,页面甚至没有加载< / p>
谢谢!
这是代码
<?php
//connection is in header
include "../Header.php";
//checks if logged in
if (!$User)
{
header("Location: ../index.php"); exit();
}
//heres the form
echo"<form><center><br /><br /><br /><br /><font size='3'><br />You are changing your Post Color<br />
Your current color is $myU->PostColor<br /><br /></font><form>
Color:<br /><textarea name='color' rows='1' cols='15'></textarea><br /><br />
<input type='submit' name='Submit' value='submit'></form></center></form>";
$Color = mysql_real_escape_string(strip_tags($_POST['Color']));
$submit = mysql_real_escape_string(strip_tags($_POST['submit']));
if ($submit) {
mysqli_query("UPDATE `socialli_main`.`Users` SET `PostColor` = '$Color' WHERE `Users`.`ID` ='$myU->ID'");
header("Location: ../index.php"); exit();
}
include "../Footer.php";
答案 0 :(得分:1)
提交按钮将提交其中的表单。你根本没有<form>
元素。你需要添加一个。
答案 1 :(得分:0)
更重要的是,添加<form>
标签实际上是在其上设置属性。请尝试以下方法。
<form action='' method='POST'>
您还多次结束</form>
代码......
以下是我修改代码的方法:
<?php
//connection is in header
include "../Header.php";
//checks if logged in
if (!$User)
header("Location: ../index.php"); exit();
?>
<form action='' method='POST'>
<div style="text-align:center;">
<br /><br /><br /><br /><br />
<span style="font-size:1.6em;">
You are changing your Post Color
</span><br>
<span style="font-size:1.3em;">
Your current color is <?=$myU->PostColor?>
</span><br>
Color:<br />
<textarea name='color' rows='1' cols='15'></textarea>
<br /><br />
<input type='submit' name='Submit' value='submit'>
</div>
</form>
<?php
$Color = mysql_real_escape_string(strip_tags($_POST['Color']));
$submit = mysql_real_escape_string(strip_tags($_POST['submit']));
if ($submit){
mysqli_query("UPDATE `socialli_main`.`Users` SET `PostColor` = '$Color' WHERE `Users`.`ID` ='$myU->ID'");
header("Location: ../index.php"); exit();
}
include "../Footer.php";
?>