我正在使用Cloud 9 IDE,並且我創建了註冊頁面,希望在用戶提交註冊憑證後重定向用戶。我試圖通過在PHP中使用標題方法來做到這一點。但是,我不知道我是否可以使用此功能,或者由於他們爲您的網站提供的網址,我是否需要解決該問題。例如,URL會,「https://example-user.c9users.io/register.php」,我嘗試使用標題是:如何在Cloud 9 IDE中使用header命令在其表單經過驗證後重定向某人?
標題(「位置:https://vomica-porixify.c9users.io/home.php」);
主要問題是,它不會工作,我不明白爲什麼。我不知道這是由於您提供的鏈接或我的註冊頁面是否被破壞。
這裏是register.php
<?php
$pageTitle = "Sign Up";
$section = "signing";
?>
<?php include 'INC/header.php'; ?>
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-body">
<div class="page-header">
<h3 class="text-center"> Register </h3>
</div>
<form class="form-horizontal" role="form" acion="process.php" method="post">
<div class="form-group">
<label for="inputUser" class="col-sm-2 control-label"> Username </label>
<div class="col-sm-10">
<div class="input-group">
<span class="input-group-addon">
<span class="glyphicon glyphicon-user"> </span>
</span>
<input type="text" class="form-control" id="inputUser" placeholder="Username">
</div>
</div>
</div>
<div class="form-group">
<label for="inputEmail" class="col-sm-2 control-label"> E-Mail </label>
<div class="col-sm-10">
<div class="input-group">
<span class="input-group-addon">
<span class="glyphicon glyphicon-envelope"> </span>
</span>
<input type="email" class="form-control" id="inputEmail" placeholder="E-Mail">
</div>
</div>
</div>
<div class="form-group">
<label for="inputPassword" class="col-sm-2 control-label"> Password </label>
<div class="col-sm-10">
<div class="input-group">
<span class="input-group-addon">
<span class="glyphicon glyphicon-star"> </span>
</span>
<input type="password" class="form-control" id="inputPassword" placeholder="Password">
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary"> Register </button>
<button type="button" class="btn btn-info"> User Login </button>
</div>
</div>
<?php include 'INC/redirect.php' ?>
</form>
</div>
</div>
</div>
<div class="col-md-2"></div>
</div>
<?php include 'INC/footer.php' ?>
,這裏是我的redirect.php
<?php $pageTitle = "Redirected"; ?>
<?php include 'INC/header.php' ?>
<?php
if(isset($_GET['submit'])) {
// Fetches variables from the form
$username = $_GET['inputUser'];
$email = $_GET['inputEmail'];
$password = $_GET['inputPassword'];
if(inputUser !='' && inputEmail !='' && inputPassword !='')
{
// Redirects to the page
header("Location:https://vomica-porixify.c9users.io/home.php");
} else {
?> <div class="alert alert-danger" role="alert"> <?php echo 'Please fill out all the fields!'; ?> </div> <?php
}
}
?>
<?php include 'INC/footer.php' ?>
我非常抱歉,我不小心將相同的文件包含了兩次,讓我快速解決這個問題! – Porixify
@Porixify O(∩_∩)O – sevend