Jump to content
MakeWebGames

Register.php


stabs909

Recommended Posts

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

well... how do you expect it would work? let's admit your table is called mysql_xxxxxxxxx and have only two fields (which I doubt), you would insert all the time the same username / password being username and... password. You should at least pass variables to it.

Sorry you need to learn a bit more for that read manuals tutorials. Why don't I give you the answer? First of all I have no clues of your table structure, second if I give you a working registration page (BTW you could download ezRPG or ZAP or GL and grab the registration from them) you would not learn anything.

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";

?>

 

If you planning on using it on a live site you need to escape those vars (username, password, repeatpassword).

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

May I question your methods here iExze, and I wish not to start a war...

Say a user has a strong passcode. One that, for a case of the matter, is this; <^7dhe£>Rjyydg/>

Now, Lets execute the following code.

<?php
/* 
* Look at your script, you're strip_tags'ing the password.
* I won't md5 hash it, as then we won't see the actual value.
* Compare the results with the passcode above, in blue.
*/
echo strip_tags("<^7dhe£>Rjyydg/>");
?>

 

This will output

Rjyydg/>

See the problem... ?

Link to comment
Share on other sites

May I question your methods here iExze, and I wish not to start a war...

Say a user has a strong passcode. One that, for a case of the matter, is this; <^7dhe£>Rjyydg/>

Now, Lets execute the following code.

<?php
/* 
* Look at your script, you're strip_tags'ing the password.
* I won't md5 hash it, as then we won't see the actual value.
* Compare the results with the passcode above, in blue.
*/
echo strip_tags("<^7dhe£>Rjyydg/>");
?>

 

This will output

Rjyydg/>

See the problem... ?

There was code given, it needed fixing, not things such as that taking/adding, that is up to him to work that out ;), I would never give out code that worked how I wanted it to. If you understand.

Link to comment
Share on other sites

I guess that's directed at me...

I've apologized to iExze as he pointed out that it was the OP that included the strip_tags in the first place.

I just thought I'd post that, and I quickly assumed iExze posted that, as I was quick-reading the thread, to help people understand what will happen if they use strip_tags on the passcode input where it should be complicated, like the one I posted in my reply.

I don't see how you see that isn't helpful.....

Link to comment
Share on other sites

No sniko that was directed at iExze. Dont really see the point in posting something that you perhaps know (debatable it was known) doesnt work and wouldnt post code you know does work.

What's the point in giving someone something? Telling somebody a solution straight away means they don't learn anything, instead let him post his code and find the bug himself THEN ask for help if he cannot solve it.

Of course I have different opinions to some people, so I don't want to argue over a point :).

Link to comment
Share on other sites

6 days ive been woring on the same page.

Have a look at my replies and the one iExze did, page 3, and page 1.

 

<?php
/*
* Register :: Skeleton
* Fill in the //comments
*/
if($_POST) {
/*
 * Submit button has been pressed
 * Filter / Sanitize and encrypt data  
 * Enter data into the database
 * Show success message
 */
}
?>
<h3>Register</h3>
<form action='' method='post'>
<!-- Form labels and inputs here -->
<input type='submit' value='Register' />
</form>

 

I don't see why this wouldn't work, when you add 'meat to the skeleton'

Edited by sniko
Link to comment
Share on other sites

To be honest no one has given him the first step in making a registration page...

It may help that you make a database first, before tempting to make a form, if you are wanting to store users information into a database. Then make the form, and add the INSERT query where it needs to be. Else everyone's input will not work like you want it to, because you have not created a database.

I used google here is a simple tut to give you an idea...

http://www.mikebernat.com/blog/Creating_a_Simple_Registration_Script_using_PHP

Edited by lucky3809
Link to comment
Share on other sites

6 days ive been woring on the same page.

If you have spent this long working on a simple registration page, I think it would be best to start from scratch learning from "Hello World", once you progress then you can start with more advance PHP and SQL.

Link to comment
Share on other sites

IF you're being sarcastic (hard to tell).. its a very important thing to do.

Otherwise some one could enter PHP tags, and it might execute.

You should hash a password, and that is all you need. strip_tags() is pointless once something (yes even md5()) is applied.

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...