我有这个HTML代码:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Registrazione</title>
<link href="CSSProgetto.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#000000" >
<div id="container" align="center">
<div id="logo" align="center"><img src="grafiche/NewFashion.png" width="80%" height="200px" alt=""/></div>
<p id="novitauno"> Inserire i dati per l'iscrizione: </p>
<form method="GET" action="reg.php">
<table id="reg" align="center">
<tr>
<td>Nome:</td>
<td><input type="text" name="nome"> </td>
</tr>
<tr>
<td>Cognome: </td>
<td><input type="text" name="cognome"></td>
</tr>
<tr>
<td>Email: </td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td>Nome Utente: </td>
<td><input type="text" name="username"></td>
</tr>
<tr>
<td>Password: </td>
<td><input type="text" name="pass"></td>
</tr>
<tr><td style="position:absolute" rowspan="2" align="center"><input type="submit" value=" INVIO "></td></tr>
</table>
</form>
</div>
</body>
</html>
&#13;
和这个PHP代码:
<?php
$localhost="127.0.0.1";
$utente="root";
$pass="";
$dbname="progetto";
$nome=$_GET['nome'];
$cognome=$_GET['cognome'];
$username=$_GET['username'];
$email=$_GET['email'];
$pss=$_GET['pass'];
$link=mysql_connect($localhost,$utente,$pass);
//if connection is not successful you will see text error
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db($dbname, $link);
$link=mysql_connect($localhost,$utente,$pass);
//if connection is not successful you will see text error
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_select_db($dbname, $link);
$query = "SELECT CodCliente FROM utente";
$resultnum = mysql_query($query, $link) or die('Errore...');
// conto il numero di clienti trovati nel db
$numrows = mysql_num_rows($resultnum);
if (isset($nome) && isset($cognome) && isset($username) && isset($email) && isset($pass)) {
$toinsert = "INSERT INTO utente (Nome, Cognome, Username, Email, Pass, CodCliente)
VALUES('$nome','$cognome', '$username', '$email', '$pass', '$numrows')";
//declare in the order variable
$result = mysql_query($toinsert, $link); //order executes
if($result){
echo 'Registrazione avvenuta correttamente';
}else{
echo 'Errore nella registrazione';
}
}
else echo 'No isset!';
mysql_close($link);
?>
&#13;
我不明白我做错了什么。
错误是:
注意:未定义的索引:第6行的D:\ xampp \ htdocs \ Progetto \ reg.php中的nome
注意:未定义的索引:第7行的D:\ xampp \ htdocs \ Progetto \ reg.php中的cognome
注意:未定义的索引:第8行的D:\ xampp \ htdocs \ Progetto \ reg.php中的用户名
注意:未定义的索引:第9行的D:\ xampp \ htdocs \ Progetto \ reg.php中的电子邮件
注意:未定义的索引:在第10行传递D:\ xampp \ htdocs \ Progetto \ reg.php 连接成功没有设置!
感谢您的帮助D: