Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
my code wont insert data from form into the database
Old 07-26-2010, 04:54 AM my code wont insert data from form into the database
Webmaster Talker

Posts: 611
Trades: 0
Hi, my database form doesn't work, I get no errors, please if anyone could help me by checking to see if I have any errors I'd greatly appreciate it. Thanks. Derek

Here is the code

Code:
<?php
include("connect1.php");

 
if (!empty($_POST['email']) && !empty($_POST['password']) && !empty($_POST['confirm']) && !empty($_POST['submit']))
{

    // Declare Variables
    $Email = mysql_real_escape_string($_POST['email']);
    $Password = mysql_real_escape_string($_POST['password']);
    $Confirm = mysql_real_escape_string($_POST['confirm']);
    
    // Encrypt passwords with md5 encryption
    $Password = md5($Password);
    $Confirm = md5($Confirm);
    
    if($Password != $Confirm)
    {
        echo "<br>The two passwords did not match<br>";
    
    }
    else
    {
    // Check if the email already exists in database
    
        $query = "SELECT * FROM users WHERE Email = '$Email' ";
        $results = mysql_num_rows(mysql_query($query));
        
            if ($results > 0)
            {
                echo "sorry email already exists";
             
            }
            else
            {
                // Insert information to the database
                mysql_query("UPDATE users SET Password='$Password' WHERE Email='$Email'");
                
                //Send them to login
                header("Location:http://dragonofsun.com/success.html");
            }
    
    
    }//else
    
}//if    
    
?>  
<!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>Sign up page</title>
<style type="text/css">
body {
background-color: #000000;
color: #ffffff;
}
#center_div {
vertical-align: middle;
 
}

a:link, a:hover, a:active, a:visited {
color: gold;
}
.style1 {
    font-size: larger;
    color: #FFD700;
}
</style>
</head>

<body>
 <p align="center" class="style1">Realm of the Sun Dragon sign up form</p>
<table align="center" cellpadding="10px"><tr><td> Please enter your email: <form action="signup.php" method="POST" >
<input type="text" name="email"></td></tr>
<tr><td>
 Please enter your  password:<br>
<input type="password" name="password"> 
</td></tr>
<tr><td>Please Confirm that Password:<br>
 
<input type="password" name="confirm"></td></tr>
<tr><td><input type="submit" name="submit" value="Sign Up"></form></td></tr></table>
<br /><br />
<center><font face=Arial>Copyright &copy; 2010, <a target=_blank href="http://derekvanderven.com"> by Derek Van Derven</a></font></center></body></html>
 </p>
</body>
</html>
silverglade is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-26-2010, 05:27 AM Re: my code wont insert data from form into the database
Webmaster Talker

Posts: 611
Trades: 0
nevermind, just the header location doesn't work now. Any advice GREATLY appreciated. thanks. Derek
silverglade is offline
Reply With Quote
View Public Profile
 
Old 07-26-2010, 06:39 AM Re: my code wont insert data from form into the database
Kelpie's Avatar
Skilled Talker

Posts: 82
Name: Andrew
Location: SW Scotland
Trades: 0
You should have an exit after a redirect (header location). Not sure if that's what's giving you the problem though.
Kelpie is offline
Reply With Quote
View Public Profile
 
Old 07-26-2010, 06:55 AM Re: my code wont insert data from form into the database
Webmaster Talker

Posts: 611
Trades: 0
Thank you, I used a javascript redirect instead and it worked. Thanks for looking at my code. Derek
silverglade is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to my code wont insert data from form into the database
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.62477 seconds with 12 queries