The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
Membership using PHP/MySQL
Discuss Membership using PHP/MySQL in the PHP Development forum on Dev Shed. Membership using PHP/MySQL PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

June 3rd, 2000, 02:31 PM
|
|
Registered User
|
|
Join Date: Jun 2000
Posts: 7
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
|

June 4th, 2000, 11:14 AM
|
|
Junior Member
|
|
Join Date: Jun 2000
Posts: 1
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
|

June 7th, 2000, 11:47 AM
|
|
try a linux desktop today!
|
|
Join Date: Jun 2000
Location: Vancouver
Posts: 23
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
|

June 7th, 2000, 11:56 AM
|
|
try a linux desktop today!
|
|
Join Date: Jun 2000
Location: Vancouver
Posts: 23
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
|

June 7th, 2000, 09:01 PM
|
|
Junior Member
|
|
Join Date: Jun 2000
Posts: 4
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
|

June 7th, 2000, 11:13 PM
|
|
Registered User
|
|
Join Date: Jun 2000
Posts: 7
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
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|