Jump to content
MakeWebGames

Register.php


stabs909

Recommended Posts

ok i was a bit lazy because im still new to all this but here goes. can you help me fix it when i click submit it dont work

 

<?php

echo "<h3>Register here for free account</h3>";

$submit = $_POST['submit'];

//form data

$username = strip_tags($POST['username']);

$password = md5(strip_tags($POST['password']));

$repeatpassword = md5(strip_tags($POST['repeatpassword']));

 

if ($submit)

{

echo $username;

}

?>

<html>

<form action='register.php' method='POST'>

<table>

<tr>

<td>

Choose a username:

</td>

<td>

<input type='text' name='username'>

</td>

</tr>

<tr>

<td>

Choose a Password:

</td>

<td>

<input type='password' name='password'>

</td>

</tr>

<tr>

<td>

Repeat Password:

</td>

<td>

<input type='password' name='repeatpassword'>

</td>

</tr>

</table>

<p>

<input type='submit' name='submit' value='register'>

</form

</html>

Link to comment
Share on other sites

if ($_POST['submit'])
{
$username = strip_tags($_POST['username']);
$password = md5(strip_tags($_POST['password']));
$repeatpassword = md5(strip_tags($_POST['repeatpassword']));
echo $username;

}
?>

 

That should do it I think, kinda tired, if it's wrong i'll relook it over when i get up

Link to comment
Share on other sites

It took me over a year to get my game together and I had already been coding for quite some time.

You just need to learn before continuing. Roll through tutorials which will give you the basics and then go through them again after reading on security and better methods to employ.

For example I would not use the code iExze posted.

Link to comment
Share on other sites

if ($_POST['submit'])
{
$username = strip_tags($_POST['username']);
$password = md5(strip_tags($_POST['password']));
$repeatpassword = md5(strip_tags($_POST['repeatpassword']));
echo $username;

}
?>

 

That should do it I think, kinda tired, if it's wrong i'll relook it over when i get up

Why not use mres?

Link to comment
Share on other sites

do you have an INSERT INTO VALUES if not then you wont be able to register as it not posting any input to the db

 

$username = strip_tags($_POST['username']);
$password = md5(strip_tags($_POST['password']));
$repeatpassword = md5(strip_tags($_POST['repeatpassword']));
echo $username;

$sql= "INSERT INTO `user db` ( username, password)"."VALUES ('$username', '$password');
echo 'Your account has been created successfully! <meta http-equiv="refresh" content="0; url=home.php">';
}
Edited by grant
Link to comment
Share on other sites

It took me over a year to get my game together and I had already been coding for quite some time.

You just need to learn before continuing. Roll through tutorials which will give you the basics and then go through them again after reading on security and better methods to employ.

For example I would not use the code iExze posted.

 

I wouldn't use my code, I was just re arranging the given code correctly.

 

@Grant that wouldn't insert into the db either as you never called $sql.

 

mysql_query("INSERT INTO `users` (`username`, `password`) VALUES ('".$username."', '".$password."')") or die(mysql_error());
Edited by Guest
Link to comment
Share on other sites

I wouldn't use my code, I was just re arranging the given code correctly.

 

@Grant that wouldn't insert into the db either as you never called $sql.

 

mysql_query("INSERT INTO `users` (`username`, `password`) VALUES ('".$username."', '".$password."')") or die(mysql_error());

was just example to show him how you do it lol

Link to comment
Share on other sites

was just example to show him how you do it lol

Haha sorry if it sounded harsh

 

If you are going to show him , atleast do it properly so he doesn't get mis-lead on what to do

If you are going to complain please contribute to the thread.

Link to comment
Share on other sites

the db info is before via a mysql connect.

BTW don't use mysql_query, those are old functions. If you start from scratch I would strongly suggest to use MySQLi which allows to make your code safer. (Doesn't mean you cannot be safe with the older functions, it just require more work).

Link to comment
Share on other sites

the db info is before via a mysql connect.

BTW don't use mysql_query, those are old functions. If you start from scratch I would strongly suggest to use MySQLi which allows to make your code safer. (Doesn't mean you cannot be safe with the older functions, it just require more work).

lol he cant use mysql_query yet so going to take him some time to use mysqli .i have learned php by myself and i still have some issues back and forwords stabs just google tuts on how to code php and you will soon pick it up
Link to comment
Share on other sites

LOL grant like your the expert. You dont need to learn mysql first to learn mysqli and its probably better you dont. Just go with mysqli and you will be in a much better position.
never says i was an expert say it would be easy for him to understand better
Link to comment
Share on other sites

This is my register.php code. when i click register thisshows you account created sucessful but when i go to database nothing there?

i dont understand

<html>

<title></title>

<body>

<center><img src="http://.photobucket.com/albums/ii513//Untitled-4.jpg" border="0" alt=".com"></a></center>

<head>

<style type="text/css"><!--

body {scrollbar-3dlight-color:silver;

scrollbar-arrow-color:white;

scrollbar-track-color:black;

scrollbar-darkshadow-color:gray;

scrollbar-face-color:gray;

scrollbar-highlight-color:gray;

scrollbar-shadow-color:black}

body { background-color:#404040; }

 

--></style>

</head>

</html>

<p><?php echo date("F j, g:i:s a"); ?></p>

<?php

echo "<h3>Register here for free account</h3>";

$submit = $_POST['submit'];

//form data

if ($_POST['submit'])

{

$username = strip_tags($_POST['username']);

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

$repeatpassword = md5(strip_tags($_POST['repeatpassword']));

echo $username;

error_reporting(0);

require "connect.php";

$write = mysql_query("INSERT INTO mysql_xxxxxxxxx VALUES('username','password')");

echo"<p><b>Account created sucessful</b>";

}

?>

<html>

<form action='register.php' method='POST'>

<table>

<tr>

<td>

Choose a username:

</td>

<td>

<input type='text' name='username'>

</td>

</tr>

<tr>

<td>

Choose a Password:

</td>

<td>

<input type='password' name='password'>

</td>

</tr>

<tr>

<td>

Repeat Password:

</td>

<td>

<input type='password' name='repeatpassword'>

</td>

</tr>

</table>

<p>

<left><input type='submit' name='submit' value='Register'>

</form

<p><a href='index.html'><u><b>Back to log in page</b></u></a></p>

</html>

this is my connect.php

<?php

$connect = mysql_connect("xxxxxxxx", "xxxxxxxx", "xxxxxxxx") or die ("Couldnt connect");

mysql_select_db("xxxxxxxxl") or die ("Couldnt find database");

echo "connection successful";

?>

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.

×
×
  • Create New...