gpt4 book ai didi

php - 单击按钮时方法发布不起作用

转载 作者:行者123 更新时间:2023-11-29 18:52:17 26 4
gpt4 key购买 nike

我正在尝试创建注册表单,但是当我单击“注册”按钮时什么也没有发生。我尝试检查我的代码,但看不出哪里出了问题。请帮忙。

index.php

<?php
include("Login.php");
include("saga_files/saga_index_file/saga_SignUp_file/SignUp.php");
?>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>UniSaga</title>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="css/ionicons.min.css" />
<link rel="stylesheet" href="css/font-awesome.min.css" />
<!--Google Font-->
<link href="https://fonts.googleapis.com/css?family=Lato:300,400,400i,700,700i" rel="stylesheet">

<!--Favicon-->
<link rel="shortcut icon" type="image/png" href="images/fav.png"/>
</head>
<script>
function time_get()
{
d = new Date();
mon = d.getMonth()+1;
time = d.getDate()+"-"+mon+"-"+d.getFullYear()+" "+d.getHours()+":"+d.getMinutes();
Reg.saga_join_time.value=time;
}
</script>
<header id="header-inverse">
<nav class="navbar navbar-default navbar-fixed-top menu">
<div class="container">

<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index-register.html"><img src="images/logo.png" alt="logo" /></a>
</div>

</div>
</nav>
</header>
<div id="lp-register">
<div class="container wrapper">
<div class="row">
<div class="col-sm-5">
<div class="intro-texts">
<h1 class="text-white">UniSaga</h1>
<p>Connect With Students from other Your University and Other Universities and get the latest news on what is Happening Around these learning Institutions. <br /> <br />What Are You Waiting For. Join Now And Experience It Like Never Before.</p>
</div>
</div>
<div class="col-sm-6 col-sm-offset-1">
<div class="reg-form-container">
<div class="reg-options">
<ul class="nav nav-tabs">
<li class="active"><a href="#register" data-toggle="tab">Register</a></li>
<li><a href="#login" data-toggle="tab">Login</a></li>
</ul><!--Tabs End-->
</div>

<!--Registration Form Contents-->
<div class="tab-content">
<div class="tab-pane active" id="register">
<h3>Register Now !!!</h3>
<p class="text-muted">Its Free and Always Will Be.</p>

<!--Register Form-->
<form method="post" name="registration_form" id='registration_form' class="form-inline">
<div class="row">
<div class="form-group col-xs-6">
<label for="first_name" class="sr-only">First Name</label>
<input id="first_name" class="form-control input-group-lg" type="text" name="first_name" title="Enter first name" placeholder="First name"/>
</div>
<div class="form-group col-xs-6">
<label for="last_name" class="sr-only">Last Name</label>
<input id="last_name" class="form-control input-group-lg" type="text" name="last_name" title="Enter last name" placeholder="Last name"/>
</div>
</div>
<div class="row">
<div class="form-group col-xs-12">
<label for="email" class="sr-only">Email</label>
<input id="email" class="form-control input-group-lg" type="text" name="email" title="Enter Email" placeholder="Your Email"/>
</div>
<div class="form-group col-xs-12">
<label for="remail" class="sr-only">Re-Enter Email</label>
<input id="remail" class="form-control input-group-lg" type="text" name="remail" title="Enter Email" placeholder="Re-Enter Your Email"/>
</div>

</div>
<div class="row">
<div class="form-group col-xs-12">
<label for="password" class="sr-only">Password</label>
<input id="password" class="form-control input-group-lg" type="password" name="password" title="Enter password" placeholder="Password"/>
</div>
</div>
<div class="row">
<p class="birth"><strong>Date of Birth</strong></p>
<div class="form-group col-sm-3 col-xs-6">
<label for="month" class="sr-only"></label>
<select name="day" class="form-control" id="Day">
<option value="Day" disabled selected>Day</option>
<script type="text/javascript">

for(i=1;i<=31;i++)
{
document.write("<option value='"+i+"'>" + i + "</option>");
}

</script>
</select>
</div>
<div class="form-group col-sm-3 col-xs-6">
<label for="month" class="sr-only"></label>
<select name="month" class="form-control" id="Month">
<option value="Month" disabled selected>Month</option>
<script type="text/javascript">

var m=new Array("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
for(i=1;i<=m.length-1;i++)
{
document.write("<option value='"+i+"'>" + m[i] + "</option>");
}
</script>
</select>
</div>
<div class="form-group col-sm-6 col-xs-12">
<label for="year" class="sr-only"></label>
<select name="year" class="form-control" id="Year">
<option value="Year" disabled selected>Year</option>
<script type="text/javascript">

for(i=2000;i>=1960;i--)
{
document.write("<option value='"+i+"'>" + i + "</option>");
}

</script>
</select>
</div>
</div>
<div class="form-group gender">
<select name="sex" style="width:120;height:35;font-size:18px;padding:3;">
<option value="Select Sex:"> Select Sex: </option>
<option value="Female"> Female </option>
<option value="Male"> Male </option>
</select>
</div>
<div class="row">
<div class="form-group col-xs-6">
<label for="campus" class="sr-only">Campus</label>
<input id="campus" class="form-control input-group-lg reg_name" type="text" name="campus" title="Enter campus" placeholder="Your campus"/>
</div>
<div class="form-group col-xs-6">
<label for="county" class="sr-only"></label>
<select name="county" class="form-control" id="county">
<option value="county" disabled selected>County</option>
<option value="Baringo">Baringo</option>
<option value="Bomet">Bomet</option>
<option value="Bungoma">Bungoma</option>
<option value="Busia">Busia</option>
<option value="Elgeyo">Elgeyo Marakwet</option>
<option value="Embu">Embu</option>
<option value="Garissa">Garissa</option>
<option value="Homa">Homa Bay</option>
<option value="Isiolo">Isiolo</option>
<option value="Kajiado">Kajiado</option>
<option value="Kakamega">Kakamega</option>
<option value="Kericho">Kericho</option>
<option value="Kiambu">Kiambu</option>
<option value="Kilifi">Kilifi</option>
<option value="Kirinyaga">Kirinyaga</option>
<option value="Kisii">Kisii</option>
<option value="Kisumu">Kisumu</option>
<option value="Kitui">Kitui</option>
<option value="Kwale">Kwale</option>
<option value="Laikipia">Laikipia</option>
<option value="Lamu">Lamu</option>
<option value="Machakos">Machakos</option>
<option value="Makueni">Makueni</option>
<option value="Mandera">Mandera</option>
<option value="Meru">Meru</option>
<option value="Migori">Migori</option>
<option value="Marsabit">Marsabit</option>
<option value="Mombasa">Mombasa</option>
<option value="Muranga">Muranga</option>
<option value="Nairobi">Nairobi</option>
<option value="Nakuru">Nakuru</option>
<option value="Nandi">Nandi</option>
<option value="Narok">Narok</option>
<option value="Nyamira">Nyamira</option>
<option value="Nyandarua">Nyandarua</option>
<option value="Nyeri">Nyeri</option>
<option value="Samburu">Samburu</option>
<option value="Siaya">Siaya</option>
<option value="Taita">Taita Taveta</option>
<option value="Tana">Tana River</option>
<option value="Tharaka">Tharaka Nithi</option>
<option value="Trans">Trans Zoia</option>
<option value="Turkana">Turkana</option>
<option value="Uasin">Uasin Gishu</option>
<option value="Vihiga">Vihiga</option>
<option value="Wajir">Wajir</option>
<option value="West">West Pokot</option>
</select>
</div>
</div>
</form>
<input type="hidden" name="saga_join_time">
<button type="submit" name="signup" id="sign_button" class="btn btn-primary" / onClick="time_get()" >Register Now</button>
</div>

<div class="tab-pane" id="login">
<h3>Login</h3>
<p class="text-muted">Log into your account</p>

<!--Login Form-->
<form name="Login_form" id='Login_form'>
<div class="row">
<div class="form-group col-xs-12">
<label for="my-email" class="sr-only">Email</label>
<input id="my-email" class="form-control input-group-lg" type="text" name="username" title="Enter Email" placeholder="Your Email"/>
</div>
</div>
<div class="row">
<div class="form-group col-xs-12">
<label for="my-password" class="sr-only">Password</label>
<input id="my-password" class="form-control input-group-lg" type="password" name="password" title="Enter password" placeholder="Password"/>
</div>
</div>
</form><!--Login Form Ends-->
<p><a href="Forgot_Password.php">Forgot Password</a></p>
<button name="Login" id="login_button" class="btn btn-primary">Login Now</button>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6 col-sm-offset-6">

<!--Social Icons-->
<ul class="list-inline social-icons">
<li><a href="#"><i class="icon ion-social-facebook"></i></a></li>
<li><a href="#"><i class="icon ion-social-twitter"></i></a></li>
<li><a href="#"><i class="icon ion-social-googleplus"></i></a></li>
<li><a href="#"><i class="icon ion-social-pinterest"></i></a></li>
<li><a href="#"><i class="icon ion-social-linkedin"></i></a></li>
</ul>
</div>
</div>
</div>
</div>

<!--preloader-->
<div id="spinner-wrapper">
<div class="spinner"></div>
</div>

<!-- Scripts
================================================= -->
<script src="js/jquery-3.1.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.appear.min.js"></script>
<script src="js/jquery.incremental-counter.js"></script>
<script src="js/script.js"></script>

</body>

</html>
<?php
include("saga_files/saga_index_file/saga_erorr_file/saga_erorr.php");
?>
</body>
</html>

SignUp.php

<?php
if(isset($_POST['signup']))
{
error_reporting(1);
$connection = mysqli_connect('localhost','root','','uni-saga');
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$Email=$_POST['email'];

$que1=mysqli_query($connection,"select * from users where Email='$Email'");
$count1=mysqli_num_rows($que1);

if($count1>0)
{
echo "<script>
alert('There is an existing account associated with this email.');
</script>";
}
else
{
$Name=$_POST['first_name'].' '.$_POST['last_name'];
$Password=$_POST['password'];
$Gender=$_POST['sex'];
$Birthday_Date=$_POST['day'].'-'.$_POST['month'].'-'.$_POST['year'];
$saga_Join_Date=$_POST['saga_join_time'];
$campus=$_POST['campus'];
$county=$_POST['county'];

$day=intval($_POST['day']);
$month=intval($_POST['month']);
$year=intval($_POST['year']);
if(checkdate($day,$month,$year))
{
$que2=mysqli_query($connection,"insert into users(Name,Email,Password,Gender,Birthday_Date,saga_Join_Date,campus,county) values('$Name','$Email','$Password','$Gender','$Birthday_Date','$saga_Join_Date','$campus','$county')");

session_start();
$_SESSION['tempsagauser']=$Email;


if($Gender=="Male")
{
header("location:saga_files/saga_step/saga_step1/Step1_Male.php");
}
else
{
header("location:saga_files/saga_step/saga_step1/Step1_Female.php");
}
}
else
{
echo "<script>
alert('The selected date is not valid.');
</script>";
}
}
}
?>

最佳答案

确保表单内有按钮,并将其设置为type="submit"。还要确保在您的登录表单中也进行更改。

<form  method="post" name="registration_form" id='registration_form' class="form-inline" action="saga_files/saga_index_file/saga_SignUp_file/SignUp.php">
<div class="row">
<div class="form-group col-xs-6">
<label for="first_name" class="sr-only">First Name</label>
<input id="first_name" class="form-control input-group-lg" type="text" name="first_name" title="Enter first name" placeholder="First name"/>
</div>
<div class="form-group col-xs-6">
<label for="last_name" class="sr-only">Last Name</label>
<input id="last_name" class="form-control input-group-lg" type="text" name="last_name" title="Enter last name" placeholder="Last name"/>
</div>
</div>
<div class="row">
<div class="form-group col-xs-12">
<label for="email" class="sr-only">Email</label>
<input id="email" class="form-control input-group-lg" type="text" name="email" title="Enter Email" placeholder="Your Email"/>
</div>
<div class="form-group col-xs-12">
<label for="remail" class="sr-only">Re-Enter Email</label>
<input id="remail" class="form-control input-group-lg" type="text" name="remail" title="Enter Email" placeholder="Re-Enter Your Email"/>
</div>

</div>
<div class="row">
<div class="form-group col-xs-12">
<label for="password" class="sr-only">Password</label>
<input id="password" class="form-control input-group-lg" type="password" name="password" title="Enter password" placeholder="Password"/>
</div>
</div>
<div class="row">
<p class="birth"><strong>Date of Birth</strong></p>
<div class="form-group col-sm-3 col-xs-6">
<label for="month" class="sr-only"></label>
<select name="day" class="form-control" id="Day">
<option value="Day" disabled selected>Day</option>
<script type="text/javascript">

for(i=1;i<=31;i++)
{
document.write("<option value='"+i+"'>" + i + "</option>");
}

</script>
</select>
</div>
<div class="form-group col-sm-3 col-xs-6">
<label for="month" class="sr-only"></label>
<select name="month" class="form-control" id="Month">
<option value="Month" disabled selected>Month</option>
<script type="text/javascript">

var m=new Array("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
for(i=1;i<=m.length-1;i++)
{
document.write("<option value='"+i+"'>" + m[i] + "</option>");
}
</script>
</select>
</div>
<div class="form-group col-sm-6 col-xs-12">
<label for="year" class="sr-only"></label>
<select name="year" class="form-control" id="Year">
<option value="Year" disabled selected>Year</option>
<script type="text/javascript">

for(i=2000;i>=1960;i--)
{
document.write("<option value='"+i+"'>" + i + "</option>");
}

</script>
</select>
</div>
</div>
<div class="form-group gender">
<select name="sex" style="width:120;height:35;font-size:18px;padding:3;">
<option value="Select Sex:"> Select Sex: </option>
<option value="Female"> Female </option>
<option value="Male"> Male </option>
</select>
</div>
<div class="row">
<div class="form-group col-xs-6">
<label for="campus" class="sr-only">Campus</label>
<input id="campus" class="form-control input-group-lg reg_name" type="text" name="campus" title="Enter campus" placeholder="Your campus"/>
</div>
<div class="form-group col-xs-6">
<label for="county" class="sr-only"></label>
<select name="county" class="form-control" id="county">
<option value="county" disabled selected>County</option>
<option value="Baringo">Baringo</option>
<option value="Bomet">Bomet</option>
<option value="Bungoma">Bungoma</option>
<option value="Busia">Busia</option>
<option value="Elgeyo">Elgeyo Marakwet</option>
<option value="Embu">Embu</option>
<option value="Garissa">Garissa</option>
<option value="Homa">Homa Bay</option>
<option value="Isiolo">Isiolo</option>
<option value="Kajiado">Kajiado</option>
<option value="Kakamega">Kakamega</option>
<option value="Kericho">Kericho</option>
<option value="Kiambu">Kiambu</option>
<option value="Kilifi">Kilifi</option>
<option value="Kirinyaga">Kirinyaga</option>
<option value="Kisii">Kisii</option>
<option value="Kisumu">Kisumu</option>
<option value="Kitui">Kitui</option>
<option value="Kwale">Kwale</option>
<option value="Laikipia">Laikipia</option>
<option value="Lamu">Lamu</option>
<option value="Machakos">Machakos</option>
<option value="Makueni">Makueni</option>
<option value="Mandera">Mandera</option>
<option value="Meru">Meru</option>
<option value="Migori">Migori</option>
<option value="Marsabit">Marsabit</option>
<option value="Mombasa">Mombasa</option>
<option value="Muranga">Muranga</option>
<option value="Nairobi">Nairobi</option>
<option value="Nakuru">Nakuru</option>
<option value="Nandi">Nandi</option>
<option value="Narok">Narok</option>
<option value="Nyamira">Nyamira</option>
<option value="Nyandarua">Nyandarua</option>
<option value="Nyeri">Nyeri</option>
<option value="Samburu">Samburu</option>
<option value="Siaya">Siaya</option>
<option value="Taita">Taita Taveta</option>
<option value="Tana">Tana River</option>
<option value="Tharaka">Tharaka Nithi</option>
<option value="Trans">Trans Zoia</option>
<option value="Turkana">Turkana</option>
<option value="Uasin">Uasin Gishu</option>
<option value="Vihiga">Vihiga</option>
<option value="Wajir">Wajir</option>
<option value="West">West Pokot</option>
</select>
</div>
</div>
<button type="submit" name="signup" id="sign_button" class="btn btn-primary" / onClick="time_get()" >Register Now</button>
</form>
<input type="hidden" name="saga_join_time">

关于php - 单击按钮时方法发布不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44317752/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com