gpt4 book ai didi

javascript - 提交表单后刷新页面以显示所做操作的结果

转载 作者:行者123 更新时间:2023-11-28 02:30:43 24 4
gpt4 key购买 nike

我认为我的代码有问题,我有一个显示可用工作列表的页面,其中有两个按钮,一个用于显示工作简介“profile”,第二个用于申请工作“apply”,这是预期的结果当点击申请时,申请的工作将从所有可用工作列表中消失。该代码在本地主机上运行良好,但在将其上传到服务器后,我必须在单击“应用”后刷新页面以查看所做操作的结果。这是 AvailableJobs.php 的代码:

 <?php $sql1= "SELECT * FROM Job"; // select all the Job
$result1= mysqli_query($conn,$sql1);
while($row1=mysqli_fetch_array($result1))
{ $JobName= $row1['JobName'];
$JID= $row1['JobID'];
$OrgID= $row1['OrgID']; // get the Org ID for the available Job

$sql10=" SELECT * FROM JobStudent WHERE JobID='$JID' AND StudentID='$SID'";
$resultss = mysqli_query($conn,$sql10);
$numResults = mysqli_fetch_array($resultss);
if ($numResults == 0) {

$sql2="SELECT * FROM RequestedOrganization WHERE OrgID='$OrgID'";
$result2= mysqli_query($conn,$sql2);
while($row2=mysqli_fetch_array($result2))
{ $OrgGPA= $row2['GPA'];
$OrgTrack= $row2['Track'];
$Priority= $row2['priorityGT'];
}
?>
<li><input disabled style="border:none; margin-bottom: 10px; width:100%;" name="JobName" value="<?php echo $row1['JobName'];?>"> </li> <?php
echo "<form action='AvailableJobAction_page.php' method='POST'>
<input type='hidden' name='tempId' value='$JID'/>
<input style='border-radius: 12px; margin-bottom: 10px; background-color: #ccc;' type='submit' class='right' name='submit-btn' value='Apply' onclick='return func1()'/>
</form>";
echo "<form action='OrgProfileSS.php' method='POST'>
<input type='hidden' name='temppId' value='$JID'/>
<input type='hidden' name='tempppId' value='$OrgID'/>
<input style='border-radius: 12px; background-color: #ccc;' type='submit' name='submit-btnn' class='right' value='Profile'/>
</form><br/>"; ?>

这是执行页面 AvailableJobAction_page.php:

$USER=$_SESSION['login_user']; 

if (isset($_POST['submit-btn'])){
$Jobid=$_POST['tempId']; // J ID


$Sql="SELECT * FROM Job WHERE JobID='$Jobid'";
$Result2= mysqli_query($conn,$Sql);
while ( $Row1 =mysqli_fetch_array($Result2)){
$JN= $Row1['JobName'];
$orgid= $Row1['OrgID'];

$Sql10="SELECT * FROM Employer WHERE EmployerID='$orgid'";
$Result10= mysqli_query($conn,$Sql10);
while ( $Row10 =mysqli_fetch_array($Result10)){
$EmpEmail= $Row10['EmailAccount'];
}

}

$sql="SELECT * FROM Student WHERE KsuEmailStuent='$USER'"; // Get S ID
$result2= mysqli_query($conn,$sql);
while ( $row1 =mysqli_fetch_array($result2)){
$StID= $row1['StudentID'];
}

$sql4="SELECT * FROM JobStudent WHERE StudentID='$StID' AND JobID='$Jobid'";
$result4= mysqli_query($conn,$sql4);
$rows= mysqli_num_rows($result4);
if ($rows>0){
echo "<script type='text/javascript'>alert('You Already Applied before!')</script>";
echo "<script>window.location.href='AvailableJobs.php';</script>";
}else{
$sql4="INSERT INTO JobStudent (JobID,StudentID,Status) VALUES ('$Jobid','$StID','Pending')";
$result4= mysqli_query($conn,$sql4);

$sql1="SELECT * FROM Job WHERE JobID='$Jobid'";
$result1= mysqli_query($conn,$sql1);
while ( $row2 =mysqli_fetch_array($result1)){
$Nos= $row2['NoOfAppliedstudnets'];
}
$Nos++;
$sql3= "UPDATE Job SET NoOfstudnets='$Nos' WHERE JobID='$Jobid'";
$result3= mysqli_query($conn,$sql3);

$to = $USER; // Send Email with the new Pass
$subject = "Applied done sucsessfully!";
$message = "Your request have been sent, Please wait for response from employer and note that you can view your request status in your account home";
$message = wordwrap($message,70);
//$headers = "From : Admin@PTN.com";
if(mail($to, $subject, $message)){
echo "<script type='text/javascript'>alert('Applied done sucsessfully!')</script>";
echo "<script>window.location.href='AvailableJobs.php';</script>";
}else{
echo "<script type='text/javascript'>alert('Erorr in send Email ')</script>";
echo "<script>window.location.href='AvailableJobs.php';</script>";
}

$to = $EmpEmail; // Send Email with the new Pass
$subject = "New student have Applied!";
$message = "New student have Applied to this Job ".$JN ;
$message = wordwrap($message,70);
//$headers = "From : Admin@PTN.com";
mail($to, $subject, $message);
}
}
else echo "<script type='text/javascript'>alert('ERROR!')</script>";

最佳答案

修改部分代码:

$sql10=" SELECT * FROM JobStudent WHERE JobID='$JID' AND StudentID='$SID'";
$resultss = mysqli_query($conn,$sql10);

将检查更改为第一个 mysqli_num_rows 而不是 mysqli_fetch_array

$numResults = mysqli_num_rows($resultss);
if ($numResults == 0) {

关于javascript - 提交表单后刷新页面以显示所做操作的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47720483/

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