我在阅读HTML输入和将数据存储在会话变量中时遇到了问题,最终目标是将这些数据插入MySQL表中,因此如果有更好的方法,我也会很感激:)
<?php
session_start();
?>
<html>
<head>
<title> Blog space </title>
<head>
<body bgcolor = "EAEAEA">
<h4> Register </h4>
<form form method = "post" action = "InsertToDatabase.php">
<fieldset>
<legend style = "color:#0080c0;font-weight:bold">Register</legend>
<table>
<tr>
<td> Name: </td>
<td>
<input type = "text" name = "myName"/>
</td>
</tr>
<tr>
<td> Surname: </td>
<td>
<input type = "text" name = "mySurname"/>
</td>
</tr>
<tr>
<td> Gender: </td>
<td>
<input type = "text" name = "myGender"/>
</td>
</tr>
<tr>
<td> Date of birth: </td>
<td>
<input type = "date" name = "myDateOfBirth"/>
</td>
</tr>
<tr>
<td> Email: </td>
<td>
<input type = "email" name = "myEmail"/>
</td>
</tr>
<tr>
<td> Contact: </td>
<td>
<input type = "text" name = "myContact">
</td>
</tr>
</table>
<input style="background-color:#46A5F9;
color:white; width:19mm"
type = "submit"
value = "Submit"/>
</fieldset>
</form>
</body>
<?php
$_SESSION['name'] = $_POST['myName'];;
$_SESSION['surname'] = $_POST['mySurname'];
$_SESSION['gender'] = $_POST['myGender'];
$_SESSION['dob'] = $_POST['myDateOfBirth'];
$_SESSION['email'] = $_POST['myEmail'];
$_SESSION['name'] = $_POST['myContact'];
?>
</html>
这是我的代码,请随时让我知道,如果我遗漏了任何重要的细节。
1条答案
按热度按时间fd3cxomn1#
试试这个代码