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
Login, Check for same user ID Problem
Old 04-22-2005, 11:28 AM Login, Check for same user ID Problem
merlin's Avatar
Skilled Talker

Posts: 52
Trades: 0
Hello,

I'm having a small problem getting my code to check for existing user names on my database. I have attached my PHP code that I'm having issues with and I was hoping that someone could see where I went wrong.


Thanks........
PHP Code:
    if (isset($_POST['submit'])) {
    
        include(
'mysql_connect_login.php');

$frm_ID $_POST['username']; 

    
$query "SELECT username FROM users WHERE username= $frm_ID";
    
$r mysql_query ($query);
if (
mysql_num_rows($r) == 0) {
    
$sql_query "insert into users (Name, username, password, transit) Values ('{$_POST['name']}', '{$_POST['username']}', '{$_POST['password']}', '{$_POST['transit']}')";
    
//run it 
    
$query_run mysql_query($sql_query);
    
$query_run;

} else {
header("location: inuse.php");
}


    
mysql_close();
    
header("location: updated.php");


Last edited by merlin; 04-22-2005 at 11:54 AM..
merlin is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-22-2005, 01:26 PM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
no single quotes around $frm_ID assuming it's that query that's failing.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 04-22-2005, 03:46 PM
Phaedrus's Avatar
Ultra Talker

Posts: 271
Location: CA
Trades: 0
I think on this part:
PHP Code:
$query_run mysql_query($sql_query);
$query_run
you don't need the second line.
__________________

Please login or register to view this content. Registration is FREE
Phaedrus is offline
Reply With Quote
View Public Profile
 
Old 04-22-2005, 04:32 PM
merlin's Avatar
Skilled Talker

Posts: 52
Trades: 0
Thanks Phaedrus, you're right I didn't need the second line but that wasn't the solution. After some very tense moments I figured out that my stucture was a mess. Here is the working code,

PHP Code:
<?php


    
if (isset($_POST['submit'])) { 
     
        include(
'mysql_connect_login.php'); 

$frm_ID $_POST['username']; 

    
$query "SELECT username FROM users WHERE username= '$frm_ID'"
    
$r mysql_query ($query); 
if (
mysql_num_rows($r) != 0) { 
    
header("location: inuse.php"); 
    } else { 
    
$sql_query "insert into users (Name, username, password, transit) Values ('{$_POST['name']}', '{$_POST['username']}', '{$_POST['password']}', '{$_POST['transit']}')"
    
//run it 
    
$query_run mysql_query($sql_query); 
    
    
header("location: updated.php"); 
    
mysql_close(); 

}
            
        
        
?>
Thanks Everyone
merlin is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Login, Check for same user ID Problem
 

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.65178 seconds with 12 queries