douzhi1813 2014-03-19 21:23
浏览 54
已采纳

初学者:IF语句/ PHP / HTML问题

I do apologise in advance for my lack of knowledge in PHP and HTML. I have scoured the internet for 3/4 days trying to create what is probably a simple system. I need the user to enter a digit before the next page is loaded. I have an IF statement on my page. 1.php

<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="css/style.css" rel="stylesheet" type="text/css" />
    <link href="css/reset.css" rel="stylesheet" type="text/css" />
<div id="container">
<div id="authorise">
<form action="2.php" method="post">
<!--Product Comment Box--><br>
<p>Please enter your 4<br> digit authorisation code:<br> <br>
<input type="text" name="digits" />
<input type="submit" name="submit" />
</form>
</div>
</div> 

2.php

<?php
  if ($_POST['digits'] === '210392') 
  {echo 'https://www.facebook.com/'
 ?>

But I need a form first which the user would input the code '210392' and press submit. Then the if statement can take place. I know how to do a form but dont know how to assign that form a variable name 'digits'. All help is appreciated.

  • 写回答

5条回答 默认 最新

  • dongyuntao2000 2014-03-19 21:32
    关注
    <form action="check.php" method="POST">
    <input type="text" name="digits" />
    <input type="submit" value="click here" />
    </form>
    
    //in check.php 
    
    if (isset($_POST['digits']) and $_POST['digits'] == 12345){
    header("Location: http://google.com");
    } 
    else {
    echo " error !!";
    }
    

    study html from w3school http://www.w3schools.com/html/html_forms.asp

    and php http://www.w3schools.com/PhP/php_forms.asp

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)