Current location: Hot Scripts Forums » Programming Languages » PHP » Need help with script

Need help with script

Reply
  #1 (permalink)  
Old 06-29-09, 02:08 PM
DarkestSoul DarkestSoul is offline
Newbie Coder
 
Join Date: Jun 2009
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Need help with script

One of my friends made a script for a site. I am not an master at script. He helped me with this one but i need to change it for a game site. I am useing justhost. It's a register script and i wanna make some changes:
change it to:
username
email
validate email
password
validate password.

can anyone help me change it so it can work with database and remove anything thats nit needed. ty
<?php

PHP Code:
// Check if he wants to register: 
if (!empty($_POST[username])) 

    // Check if passwords match. 
    if ($_POST[password] != $_POST[password2]) 
        exit("Error - Passwords don't match. Please go back and try again."); 

    // Assign some variables. 
    $date = mktime("d - m - Y"); 
    $ip = $_SERVER[REMOTE_ADDR]; 

    require_once("connect.php"); 

    // Register him. 
    $query = mysql_query("INSERT INTO members  
    (username, firstname, lastname, password, date, ip) 
    VALUES    ('$_POST[username]','$_POST[firstname]','$_POST[lastname]','$_POST[password]','$date','$ip')") 
    or die ("Error - Couldn't register user."); 
     
    echo "Welcome $_POST[username]! You've been successfully reigstered!<br /><br /> 
        Please login <a href='login.php'><b>here</b></a>."; 
    exit(); 


?> 

<html> 
    <head> 
        <title>Register</title> 
    </head> 
    <body> 
        <form action="register.php" method="post"> 
            <table width="75%" border="1" align="center" cellpadding="3" cellspacing="1"> 
                <tr> 
                    <td width="100%"><h5>Registration</h5></td> 
                </tr> 
                <tr> 
                    <td width="100%"><label>Desired Username: <input type="text" name="username" size="25" value="<? echo $_POST[username]; ?>"></label></td> 
                </tr> 
                <tr> 
                    <td width="100%"><label>First Name: <input type="text" name="firstname" size="25" value="<? echo $_POST[firstname]; ?>"></label></td> 
                </tr> 
                <tr> 
                    <td width="100%"><label>Last Name: <input type="text" name="lastname" size="25" value="<? echo $_POST[lastname]; ?>"></label></td> 
                </tr> 
                <tr> 
                    <td width="100%"><label>Password: <input type="password" name="password" size="25" value="<? echo $_POST[password]; ?>"></label></td> 
                </tr> 
                <tr> 
                    <td width="100%"><label>Verify Password: <input type="password" name="password2" size="25" value=""></label></td> 
                </tr> 
                <tr> 
                    <td width="100%"><input type="submit" value="Register!"></td> 
                </tr> 
            </table> 
        </form> 
    </body> 
</html>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 06-30-09, 01:48 AM
=OTS=G-Man =OTS=G-Man is offline
Newbie Coder
 
Join Date: Jun 2009
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
seems easy enough
PHP Code:
<?php
// Check if he wants to register:  
if (!empty($_POST[username]))  
{  
    
// Check if passwords match.  
    
if ($_POST['password'] != $_POST['password2'])  
        exit(
"Error - Passwords don't match. Please go back and try again.");  

    if (
$_POST['email'] != $_POST['email2'])
        exit(
"Error - Emails don't match. Please go back and try again.");


    
// Assign some variables.  
    
$date mktime("d - m - Y");  
    
$ip $_SERVER['REMOTE_ADDR'];  

    require_once(
"connect.php");  

    
// Register him.  
    
$query mysql_query("INSERT INTO members   
    (username, email, password, date, ip)  
    VALUES    ('"
.$_POST['username']."','".$_POST['email']."','".$_POST['password']."','$date','$ip')")  
    or die (
"Error - Couldn't register user.");  
      
    echo 
"Welcome $_POST[username]! You've been successfully reigstered!<br /><br />  
        Please login <a href='login.php'><b>here</b></a>."
;  
    exit();  
}  

?>  

<html>  
    <head>  
        <title>Register</title>  
    </head>  
    <body>  
        <form action="register.php" method="post">  
            <table width="75%" border="1" align="center" cellpadding="3" cellspacing="1">  
                <tr>  
                    <td width="100%"><h5>Registration</h5></td>  
                </tr>  
                <tr>  
                    <td width="100%"><label>Desired Username: <input type="text" name="username" size="25" value="<? echo $_POST['username']; ?>"></label></td>  
                </tr>  
                <tr>  
                    <td width="100%"><label>Email: <input type="text" name="email" size="25" value="<? echo $_POST['email']; ?>"></label></td>  
                </tr>  
                <tr>  
                    <td width="100%"><label>Verify Email: <input type="text" name="email2" size="25"></label></td>  
                </tr>  
                <tr>  
                    <td width="100%"><label>Password: <input type="password" name="password" size="25" value="<? echo $_POST['password']; ?>"></label></td>  
                </tr>  
                <tr>  
                    <td width="100%"><label>Verify Password: <input type="password" name="password2" size="25" value=""></label></td>  
                </tr>  
                <tr>  
                    <td width="100%"><input type="submit" value="Register!"></td>  
                </tr>  
            </table>  
        </form>  
    </body>  
</html>
You will still need to change the database to match the new fields
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Gallery script good/bad idea? joshg678 PHP 2 12-22-08 09:41 AM
Login Script v1.9 Problem SuavyDoodle JavaScript 8 09-28-06 10:13 PM
Help me with this script !!! phpfreek Job Offers & Assistance 0 04-12-06 06:19 PM
Is there any integrity of script rankings? webmaster@atmanager.com Hot Scripts Forum Questions, Suggestions and Feedback 17 08-06-04 01:12 AM


All times are GMT -5. The time now is 08:44 PM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.