我需要将值从主页内的单元格传递到另一页面。
我必须通过:9.00
Username
week
year
NULL
。最后3个在我的数据库中返回0
的输入中定义。前2名返回null
。所有这些值应该在主页面中已知,因此用户不必插入任何内容。
用户名甚至在主页面之前打印。输入需要用户采取某种行动吗?如果是这样(可以解释0
和// First cell form to pass data to booking.php
<?php
$week = date("W");
$year = (isset($_GET['year']))?$_GET['year']:date("Y");
$week = (isset($_GET['week']))?$_GET['week']:Date('W');
if($week>52){
$year+= 1;
$week=1;
}elseif($week < 1) {
$year--;
$week = 52;
}
?>
<a href="<?php echo $_SERVER['PHP_SELF'].'?week='.($week-1).'&year='.$year; ?>">Pre Week</a> <!--Settimana Precendete-->
<a href="<?php echo $_SERVER['PHP_SELF'].'?week='.($week+1).'&year='.$year; ?>">Next Week</a> <!--Settimana Prossima-->
<table border="1px" class="WeekLayout">
<tr>
<td>Schedule</td>
<?php
if($week < 10) {
$week = '0'. $week;
}
for($day=1; $day<=7; $day++)
{
$d = strtotime($year."W".$week.$day);
echo "<td>".date('l',$d )."<br>";
echo date('d M Y',$d)."</td>";
}
?>
</tr>
<form action="Booking.php" method="POST" name="BookingForm" id="BookingForm">
<tr class="9">
<td>9.00
</td>
<td class="free" onclick="Change(this)"><a href=""> </a>
<input type="hidden" name="Monday">
<input type="hidden" name="9.00"></td>
<td class="free" onclick="Change(this)"><a href=""></a></td>
<td class="free" onclick="Change(this)"><a href=""></a></td>
<td class="free" onclick="Change(this)"><a href=""></a></td>
<td class="free" onclick="Change(this)"><a href=""></a></td>
<td class="free" onclick="Change(this)"><a href=""></a></td>
<td class="free" onclick="Change(this)"><a href=""></a></td>
</tr>
<tr>
</table>
<input type="hidden" name="$Username">
<input type="hidden" name="$week">
<input type="hidden" name="$year">
<input value="Prenota" type="submit" class="buttonsubmit" id="Prenota">
</form>
</div>
//Connection to database
<?php
$user = 'root';
$password = '';
$db = 'elencoprenotazioni';
$host = 'localhost';
$dblink2 = new mysqli($host, $user, $password, $db)
or die("Connessione non riuscita: " . mysqli_error());
?>
//Prenotation system
<?php
include("Connessione2.php");
session_start();
$Username = $_POST['Username'];
$week = $_POST['week'];
$year = $_POST['year'];
$day = $_POST['day'];
$hour = $_POST['hour'];
$queryinsert = mysqli_query($dblink2, "INSERT INTO calendario (Username, week, year, day, hour) VALUES ('$Username','$week','$year','$day','$hour')");
if($queryinsert)
{
header("location: index.html");
}
mysqli_close();
?>
值)如何在不必让用户插入内容的情况下传递值?
这是代码和一些描述我情况的屏幕。
0
在我的数据库中这样做我只得到了这个:
正如您所看到的,我得到null
表示应该在我的主页面中的值,week
表示我在表单中定义的值。
页面的完整视图:
正如您从网址year
中看到的那样,我们应该知道Username
并且在注销按钮附近打印 class WebService{
public static List<user> UserLoglist = new List<user>();//list of logged in users
[WebMethod(Description = "Per session Hit Counter", EnableSession = true)]
public void ClnUpdateFlag(string un)//gets called via ajax
{//Updates the flags i
//update users status
WebService.UserLoglist.Find(y => y.username == un).isLoggedin = true;
}
}
public class user
{
public string username;
public System.Timers.Timer timScheduledTask = new System.Timers.Timer();
public bool isLoggedin = true;
public user(string puser)
{
username = puser;
setimer(); //set server side timer
}
void Timer1_Tick(object sender, EventArgs e)
{
...
if (isLoggedin)// window is still open
isLoggedin = false;
else// user closed the window
{
...
WebService.UserLoglist.RemoveAll(x => x.username == username);// instance is deleted here
...
}
}
}
void setimer()
{
timScheduledTask.Interval = 3000;
timScheduledTask.Enabled = true;
timScheduledTask.Start();
timScheduledTask.Elapsed +=
new System.Timers.ElapsedEventHandler(Timer1_Tick);
}
}
。
答案 0 :(得分:0)
为什么在name属性中使用值?
请更改这些......
<input type="hidden" name="Monday">
<input type="hidden" name="9.00"></td>
<input type="hidden" name="$Username">
<input type="hidden" name="$week">
<input type="hidden" name="$year">
到第一个
<input type="hidden" name="day" value="Monday">
<input type="hidden" name="hour" value="9.00"></td>
<input type="hidden" name="Username" name="MyUsername">
<input type="hidden" name="week" name="53">
<input type="hidden" name="year" name="2016">