Jump to content
php.lv forumi

register


student

Recommended Posts

Tagad man ir pilns register un viss notiek,vienīgi,kad ir dati ievietoti iekšā db tad firefox atver lapu ar tekstu:"Problēma ar lapas ielādi".Ko man darīt lai tas tā nenotiek (visas adreses ievietotas pareizi!)?

 

Šis ir register.html -->

 

<form name="login" method="post" action="register.php">

<table border="0" width="225" align="center">

<tr>

<td width="219" bgcolor="#999999">

<p align="center"><font color="white"><span style="font-size:12pt;"><b>Registration</b></span></font></p>

</td>

</tr>

<tr>

<td width="219">

<table border="0" width="282" align="center">

<tr>

<td width="116"><span style="font-size:10pt;">Name:</span></td>

<td width="156"><input type="text" name="name" maxlength="100"></td>

</tr>

<tr>

<td width="116"><span style="font-size:10pt;">Email:</span></td>

<td width="156"><input type="text" name="email" maxlength="100"></td>

</tr>

<tr>

<td width="116"><span style="font-size:10pt;">Username:</span></td>

<td width="156"><input type="text" name="username"></td>

</tr>

<tr>

<td width="116"><span style="font-size:10pt;">Password:</span></td>

<td width="156"><input type="password" name="password"></td>

</tr>

<tr>

<td width="116"> </td>

<td width="156">

<p align="right"><input type="submit" name="submit" value="Submit"></p>

</td>

</tr>

</table>

</td>

</tr>

<tr>

<td width="219" bgcolor="#999999"> </td>

</tr>

</table>

</form>

 

 

Šis ir register.php -->

 

<?php

 

//Database Information

 

$dbhost = "localhost";

$dbname = "users";

$dbuser = "root";

$dbpass = "";

 

//Connect to database

 

mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());

mysql_select_db($dbname) or die(mysql_error());

 

 

$name = $_POST['name'];

$email = $_POST['email'];

$username = $_POST['username'];

$password = md5($_POST['password']);

 

// lets check to see if the username already exists

 

$checkuser = mysql_query("SELECT username FROM users WHERE username='$username'");

 

$username_exist = mysql_num_rows($checkuser);

 

if($username_exist > 0){

echo "I'm sorry but the username you specified has already been taken. Please pick another one.";

unset($username);

include 'register.html';

exit();

}

 

// lf no errors present with the username

// use a query to insert the data into the database.

 

$query = "INSERT INTO users (name, email, username, password)

VALUES('$name', '$email', '$username', '$password')";

mysql_query($query) or die(mysql_error());

mysql_close();

 

echo "You have successfully Registered";

 

?>

Edited by student
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...