2017-02-03 58 views
0

如果我点击提交它只刷新网站。 connect.php是正确的。但有些事情必须是错误的。mysql脚本只能重新加载

in.php

<form id="mathe1" action="script.php" method="post"> 
    <input name="nummer" type="number" value=""/><br><br> 
    <label id="label"><p>Hausübung</p></label> 
    <textarea name="hu" cols="60" rows="5"></textarea><br><br> 
    <input name="Submit1" type="submit" value="Senden"/> 
</from> 

的script.php:

<?php  
include('include/connect.php'); 

$nummer = $_POST['nummer']; 
$hu = $_POST['hu']; 
$db = "hu"; 

if (empty($nummer)) { 
    header('Location:in.php'); 
} 
if (empty($hu)) { 
    header('Location:in.php'); 
} 
else { 
    $sql = "INSERT INTO $db VALUES ('$nummer','$hu')"; 
    $query = mysql_query($sql); 
} 
?> 
+0

FYI您的交易

标签有一个错字'' –

回答

0

您似乎错误定义的if语句和位置应绝对定义,因此:

在include /连接.php

$mysqli = new mysqli('sqlhost', 'user', 'password', 'db'); 

在scpipt.php

$nummer = $_POST['nummer']; 
    $hu = $_POST['hu']; 
    $table = "hu"; 
    $url = "http://yourdevhost/in.php"; 

    if (empty($nummer) || empty($hu)) { 
    header('Location: '.$url); 
    } else { 
    $stmt = $mysqli->prepare('INSERT INTO ? VALUES (?, ?)'); 
    $stmt->bind_param('sss', $table, $nummer, $hu); 
    $stmt->execute(); 
    } 
+0

OUH对不起,我在我的脚本这样做。我只在stackoverflow代码中忘了它。 – Basty

+0

和与怎么样这只是在这里或你的来源打字错误? –

+0

还有一个错别字 – Basty