Post方法无法在线工作

时间:2017-06-03 08:54:53

标签: php post

我想通过PHP MySQL输入一些数据。所以我编写了一个表单,一个类中的方法和一个控制器来处理整个事情,它与localhost工作正常,根据编程逻辑插入数据,但在线表单post方法不起作用。没有数据发送到控制器页面。我对这个问题感到无助。 如下所示。

 <form method="post" action="registrationcontroller.php">
    <input type="text" name="name" class="form-control" placeholder="Enter your name" required/><br/>
    <input type="text" name="phone"  class="form-control" placeholder="Enter your phone" required/><br/>
    <input type="email" name="email"  class="form-control" placeholder="Enter your email" required/><br/>
    <input type="text" name="callsign"  class="form-control" placeholder="Enter your call sign if any" ><br/>
    <input type="text" name="location" class="form-control" placeholder="Enter your location" required/><br/>
    <textarea name="address" class="form-control" placeholder="Enter your full address"></textarea> <br/>
    <input type="submit" class="btn btn-primary" name="add">
</form>

这是我的控制器代码

require_once 'Registrationclass.php';
$registration = new Registrationclass();

if(isset($_POST['add']))
{

    if(isset($_POST["name"])){
        $name = $_POST['name'];
    }   
    if(isset($_POST["phone"])){
        $phone = $_POST['phone'];
    }   
    if(isset($_POST["email"])){
        $email = $_POST['email'];
    } 

    if(isset($_POST["location"])){
        $location = $_POST['location'];
    } 
    if(isset($_POST["callsign"])){
        $callsign = $_POST['callsign'];  
    } 
    if($callsign=="") {
        $callsign="SWL";
    }
    if(isset($_POST["address"])){
        $address = $_POST['address'];
    } 
}
$registration->setName($name);  
$registration->setEmail($email);
$registration->setPhone($phone);
$registration->setLocation($location);
$registration->setAddress($address);
$registration->setCallsign($callsign);
$registration->setStatus("Pending");

$registrationid= "JCBIARF-".rand(1000,3000); 
$registration->setRegistrationid($registrationid); 
$registration->adduser();
$registration->redirect("registration.php?regsuc=true");

请帮助解决问题。

0 个答案:

没有答案