PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 3rd, 2000, 02:31 PM
kankohi kankohi is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 7 kankohi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 53 m 15 sec
Reputation Power: 0
Hi, newbie question here,

I'm trying to use PHP and MySQL to implement a membership form....

My initial page is addform.php3 :
<form method="post" action="confirm.php3">
<p>
<font color="#00004D">First Name</font><br>
<input type="text" name="FIRST_NAME"> </p>
<p>Last Name<br>
<input type="text" name="LAST_NAME">
</p>
<p>Password<br>
<input type="password" name="PASSWORD">
</p>
<p>Email<br>
<input type="text" name="EMAIL">
</p>
<p><input type="submit" name="Submit" value="Submit">
<input type="reset" name="Submit2" value="Reset">
</form>


Which loads up "Confirm.php3", which looks like this:
$server= "localhost"; //mysql server address
$dbname= "mydbname"; // mysql database name
$uid= "myusername"; // username for that database
$pwd= "mypassword"; // password for that database

if (($REQUEST_METHOD=='post')) {
$query = "INSERT INTO MEMBERS";
$query .= "(FIRST_NAME, LAST_NAME,";
$query .= "EMAIL, PASSWORD)";
$query .= "values('$FIRST_NAME','$LAST_NAME','$EMAIL','$PASSWORD')";

$conn=mysql_connect($server,$uid,$pwd) or die("Unable to connect to SQL server");
mysql_select_db($dbname, $conn) or die("Unable to select database");

mysql_query($query) or die("Insert Failed!");


However, this just doesn't seem to work! No members are added and I'm getting no errors. Could someone tell me what I'm doing wrong?

thanks in advance,
kankohi

Reply With Quote
  #2  
Old June 4th, 2000, 11:14 AM
scooter scooter is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 1 scooter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Greetings,
I am also a bit of a newbie but consider adding an else to the conditional statement to test if the first condition is evaluating false, as it is if this:

if (($REQUEST_METHOD=='post')) {

fails (that is if it evaluates false), then execution will stop and you will get no errors and no users added to your DB. Also I'm not sure you need (( *** )) double parens around the conditional statement it's not "if ((this | | (this)) {}"... it's
"if (this) {}"...
Otherwise looks fine to me.
Best
Scott


Reply With Quote
  #3  
Old June 7th, 2000, 11:47 AM
jayrb jayrb is offline
try a linux desktop today!
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Location: Vancouver
Posts: 23 jayrb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 12 m 58 sec
Reputation Power: 0
Hi,

I'm real green, and am trying to do a membership system as well. I have my registration form much like yours with a couple differences.

Not sure why yer asking 'if((REQUEST...' - I have used the get method from my form which works.

The other difference is that I haven't built up my query as you. "$query .="

I just wrote one long line with my column names $tablename (firstName,lastName...) hit 'return' and did VALUES ('$firstName','$lastName'...)"; closing with "; It is my understanding that php does not care about line breaks unless it sees the ';'.

Your approach may certainly be valid (I wouldn't know ) but I do know mine works.

Jay

Reply With Quote
  #4  
Old June 7th, 2000, 11:56 AM
jayrb jayrb is offline
try a linux desktop today!
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Location: Vancouver
Posts: 23 jayrb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 12 m 58 sec
Reputation Power: 0
Sorry, addendum

What I meant is that I don't nest my connection stuff in an 'if' statement. It's just there and runs as it reads.

JB

Reply With Quote
  #5  
Old June 7th, 2000, 09:01 PM
enka enka is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 4 enka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi all, URL

I just wonder, why did you try to check the "if" condition using "$REQUEST_MODE". In my day programming I ussually use the button name to validate.

This makes easy to determine which button is pressed when there are more than 1 button. To catch the button name I check with "if ($btn_name) ...".

But if there is a special purpose to use "$REQUEST_MODE" can you explain more?

Regards,
enka

Reply With Quote
  #6  
Old June 7th, 2000, 11:13 PM
kankohi kankohi is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 7 kankohi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 53 m 15 sec
Reputation Power: 0
Thanks for all your help,

I got it to work, just changed $Request_method = "post" to "get"

again, my thanks,
kankohi

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Membership using PHP/MySQL

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap