好的,我已经发布了这个,但仍然没有找到解决方案。我似乎无法使我的表格保持在同一页面上,我基本上已经尝试了我能想到的一切。
<?php include("inc\incfiles\header.inc.php"); ?>
<?php
$reg = @$_POST['reg'];
//declaring variables to prevent errors
$fn = $ln = $un = $em = $em2 = $pswd = $pswd2 = $d = $u_check = "";
/*$fn = ""; //First Name
$ln = ""; //Last Name
$un = ""; //Username
$em = ""; //Email
$em2 = ""; //Email 2
$pawd = ""; //:Password
$pawd2 = ""; //Password 2
$d = ""; //Sign up Date
$u_check = ""; //Check if username exists*/
//registration form
$fn = mysql_real_escape_string(@$_POST['fname']);
$ln = mysql_real_escape_string(@$_POST['lname']);
$un = mysql_real_escape_string(@$_POST['username']);
$em = mysql_real_escape_string(@$_POST['email']);
$em2 = mysql_real_escape_string(@$_POST['email2']);
$pswd = mysql_real_escape_string(@$_POST['password']);
$pswd2 = mysql_real_escape_string(@$_POST['password2']);
$d = date("Y-m-d"); //Year - Month - Day
if ($reg)
{
//check all of the fields have been filled in
if ($fn && $ln && $un && $em && $em2 && $pswd && $pswd2) {
}
else{
echo "please fill in all fields...";
}
}
?>
<table class="homepageTable">
<tr>
<td width="60%" valign="top">
<center><h2>Join the community today!</h2></center>
<center><img src="images/photo.png" width="500"></center>
<form>
</td>
<td width="40%" valign="top">
<h2>Get started below...</h2>
<form action="#" method="post">
<input type="text" size="25" name="firstname" placeholder="First Name" value="<?php echo $fn; ?>"/>
<input type="text" size="25" name="lastname" placeholder="Last Name" value="<?php echo $ln; ?>"/>
<input type="text" size="25" name="username" placeholder="Username" value="<?php echo $un; ?>"/>
<input type="text" size="25" name="email" placeholder="Email" value="<?php echo $em; ?>">
<input type="text" size="25" name="email2" placeholder="Repeat Email" value="<?php echo $em2; ?>"/>
<input type="password" size="32" name="password" placeholder="Password"/>
<input type="password" size="32" name="password2" placeholder="Repeat Password"/><br />
<input type="submit" name="reg" value="Sign Up!"/>
</form>
</td>
</tr>
</table>
我最大的问题是:
<form action="#" method="post">
<input type="text" size="25" name="firstname" placeholder="First Name" value="<?php echo $fn; ?>"/>
<input type="text" size="25" name="lastname" placeholder="Last Name" value="<?php echo $ln; ?>"/>
<input type="text" size="25" name="username" placeholder="Username" value="<?php echo $un; ?>"/>
<input type="text" size="25" name="email" placeholder="Email" value="<?php echo $em; ?>">
<input type="text" size="25" name="email2" placeholder="Repeat Email" value="<?php echo $em2; ?>"/>
<input type="password" size="32" name="password" placeholder="Password"/>
<input type="password" size="32" name="password2" placeholder="Repeat Password"/><br />
<input type="submit" name="reg" value="Sign Up!"/>
</form>
我希望能够按下提交按钮并使其保持在同一页面上。 我试过留下空白我已经尝试了一些其他建议,但我一直没有提出任何建议。我一直试图弄清楚它已经2天了,它不会让步。当我在xampp上按下我的网站上的提交按钮时,它只是带我到另一个页面上说OBJECT NOT FOUND ...等。
如果有人可以提供帮助,我们将不胜感激!我真的不想因为一个错误而不得不重新开始我的编码。
的header.inc.php
<?php
include("inc/scripts/mysql_connect.inc.php");
?>
<html>
<head>
<link href="css\main.css" rel="stylesheet" type="text/css">
<title>website</title>
</head>
<body>
<div class="headerMenu">
<div id="wrapper">
<div class="logo">
<img src="images/Logo.png">
</div>
<div class="search_box">
<form method="GET" action="search.php" id="search">
<input name="q" type="text" size="60" placeholder="Search..."
</form>
</div>
<div id="menu">
<a href="#">Home</a>
<a href="#">About</a>
<a href="#">Sign Up</a>
<a href="#">Log in</a>
</div>
</div>
<br />
<br />
<br />
<br />
答案 0 :(得分:1)
尝试使用$ _SERVER ['PHP_SELF'] http://php.net/manual/en/reserved.variables.server.php
答案 1 :(得分:1)
通过停留在同一页面,我认为您的意思是要提交页面,刷新&amp;发送数据。如果您的意思是,那么您可以将其用作标记:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" >
但是,如果您希望不刷新页面,则需要使用Jquery,JavaScript等。
答案 2 :(得分:0)
而不是形式action="#"
写form action=""
注意,有2个刻度,其间没有任何内容。
答案 3 :(得分:0)
您的问题就在inc\incfiles\header.inc.php
<input name="q" type="text" size="60" placeholder="Search..."
您缺少结束括号 -
<input name="q" type="text" size="60" placeholder="Search..." />
^^
因此,下一行的结束表单标记未被解析,因此index.php
中的表单位于<form method="GET" action="search.php" id="search">