我已经在 php 中编写了一些用于用户注册的代码,但是如果我单击提交按钮,它没有写入数据库。请帮助我。这是我的代码...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Register - Vatsal Technosoft Messenger</title>
<link href="Style/regstyle.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php include 'connect.php'; ?>
<?php include 'functions.php'; ?>
<div id="outer">
<div id="companyname"></div>
<div class="container">
<div id="formcontainer">
<h3>Registration Form </h3>
<form name="register_form" action="" method="post">
<?php
if( isset($_POST['register']) AND
isset($_POST['username']) AND
isset($_POST['password']) AND
isset($_POST['firstname']) AND
isset($_POST['lastname']) AND
isset($_POST['contact1']) AND
isset($_POST['address']) AND
isset($_POST['jobtitle'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$fname = $_POST['firstname'];
$lname = $_POST['lastname'];
$con1 = $_POST['contact1'];
$con2 = $_POST['contact2'];
$email = $_POST['email'];
$address = $_POST['address'];
$jobtitle = $_POST['jobtitle'];
if( empty($username) or
empty($password) or
empty($fname) or
empty($lname) or
empty($con1) or
empty($email) or
empty($address) or
empty($jobtitle)) {
$message = "All Information Is neccessary";
} else {
$sql = mysql_query("INSERT INTO users VALUES (``,` $username `,` $password `,` $fname `,` $lname `,` $con1 `,` $address `,` $jobtitle `)");
if($sql) {
$message = "OK....!";
} else {
$message = "BAD";
}
}
echo "<div class='box'> $message </div>";
}
?>
<div id="formtext">
User Name : <input type="text" name="username" style="width:200px;" autocomplete="off"/>
Passwrod : <input type="password" name="password" autocomplete="off" style="width:200px;"/>
<br /><br />
First Name : <input type="text" name="firstname" style="width:200px;" autocomplete="off" />
Last Name : <input type="text" name="lastname" autocomplete = "off" style = " width:200px; "/>
<br /><br />
Contact(1) : <input type="text" name="contact1" autocomplete="off" style="width:200px;" />
Contact(2) : <input type="text" name="contact2" autocomplete="off" style="width:200px;"/>
<br /><br />
E-mail ID : <input type="text" name="email" autocomplete="off" style="width:300px;"/>
<br /><br />
Address :<br />
<textarea name="address" cols="25" rows="5" autocomplete="off" style="background: #333;color: #fff;border-radius:5px;border: 0px; margin-top:-20px;" placehoder="Address"></textarea>
<br /><br />
Job Title : <input type="text" name="jobtitle" autocomplete="off" style="width:215px;"/>
<br /><br /><br />
<input type="button" name="back" value="Back" style="width:100px; margin-left:95px;"/>
<input type="reset" name="reset" value="Reset" style="width:100px; margin-left:45px;"/>
<input type="submit" name="register" value="Register" style="width:100px; margin-left:45px;"/>
</div>
</form>
</div>
</div>
</div>
</body>
</html>