我对php很新。当我尝试通过PHP注册表单时。数据 s被提交到数据库,但重定向到特定页面失败。
我的登录表单在根目录中名为index.php。和我在二级目录中的注册表。我的注册表单控件位于第一级目录中。我使用php_fetch进行url sanitize。这是我的文件夹结构 -
根 - > INC(文件夹) - >的index.php
INC(文件夹) - >页(文件夹) - > registration.con.php
页(文件夹) - > registrster.php
这是我的表单控件
<form class="js-validation-register form-horizontal push-50-t push-50" action="<?php echo esc_url($_SERVER['PHP_SELF']); ?>" method="post" name="registration_form">
<div class="form-group">
<div class="col-xs-12">
<div class="form-material form-material-success">
<input class="form-control" type="text" id="username" name="username" placeholder="Please enter a username">
<label for="username">Username</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<div class="form-material form-material-success">
<input class="form-control" type="email" id="email" name="email" placeholder="Please provide your email">
<label for="email">Email</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<div class="form-material form-material-success">
<input class="form-control" type="password" id="password" name="password" placeholder="Choose a strong password..">
<label for="password">Password</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<div class="form-material form-material-success">
<input class="form-control" type="password" id="confirmpwd" name="confirmpwd" placeholder="..and confirm it">
<label for="register-password2">Confirm Password</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<label class="css-input switch switch-sm switch-success">
<input type="checkbox" id="register-terms" name="register-terms"><span></span> I agree with terms & conditions
</label>
</div>
</div>
<div class="form-group">
<div class="col-xs-12 col-sm-6 col-md-5">
<input class="btn btn-block btn-success" type="button"
value="Register"
onclick="return regformhash(this.form,
this.form.username,
this.form.email,
this.form.password,
this.form.confirmpwd);" />
</div>
</div>
</form>
这是我的php_fwtch函数
function esc_url($url) {
if ('' == $url) {
return $url;
}
$url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\\x80-\\xff]|i', '', $url);
$strip = array('%0d', '%0a', '%0D', '%0A');
$url = (string) $url;
$count = 1;
while ($count) {
$url = str_replace($strip, '', $url, $count);
}
$url = str_replace(';//', '://', $url);
$url = htmlentities($url);
$url = str_replace('&', '&', $url);
$url = str_replace("'", ''', $url);
if ($url[0] !== '/') {
// We're only interested in relative links from $_SERVER['PHP_SELF']
return '';
} else {
return $url;
}
}
正如您所看到的,当我在成功时注册表单时,它应该将我重定向到../../index.php但是它将它重定向到../index.php,其中registeration.con.php和函数exsits。 !
这个错误即将成功登记..
未找到
在此服务器上找不到请求的URL /src3/inc/index.php。
我知道它正在重定向到inc文件夹上的索引页面..但是我必须将它重定向到根目录上的索引页面..
请帮帮我..