我在php中遇到了会话问题。
这是 index.php
<form method="post" action="send.php">
No. HP Tujuan : <input type="text" name="nohp" value="+62"><br>
Pesan : <textarea name="msg"></textarea><br>
<input type="submit" name="submit" value="Kirim SMS">
</form>
和 send.php
<?php
mysql_connect("dbhost", "dbuser", "dbpass");
mysql_select_db("sms");
$noTujuan = $_POST['nohp'];
$message = $_POST['msg'];
$query = "INSERT INTO outbox (DestinationNumber, TextDecoded, CreatorID) VALUES ('$noTujuan', '$message', 'Gammu')";
$hasil = mysql_query($query);
if ($hasil) echo "SMS Success";
else echo "SMS Failed";
?>
我想创建一个会话,但我不知道如何。我希望send.php页面只有在用户已经在index.php中完成表单时才能访问。
答案 0 :(得分:0)
解决了,谢谢你们
<?php
if (isset($_POST['nohp']) AND isset($_POST['msg']))
{
$noTujuan=$_POST['nohp'];
$message=$_POST['msg'];
}
else
{
die("access this page from index.php");
}
if (!empty($noTujuan))
{
echo "No. HP: $noTujuan <br /> Isi Pesan: $message";
}
else
{
die(sorry, you must entry name");
}
?>