08-24-2005
|
#1 (permalink)
|
|
Registered User
Join Date: Aug 2005
Posts: 15
|
PHP problem - please help
Hi guys,
I'm having a little problem with my php. I have a membership database setup and it works fine with the exception of what should be a simple but annoying problem.
I have a form selection box which gets its options content from the database and lists the $fullname variable in it. What I am trying to do is let the user click on the name of the person and then click the delete button. Once there, it will bring the user to another page that shows the account information details and asks for a confirmation of the deletion. However, after selecting a name and clicking the delete button, the next page does not show the member information. It will show the page properly, but the spaces where the member information should be is blank.
I have tested different things and my conclusion is that the selection form is not getting the $fullname variable to the account_delete.php script. If you would like to see it first hand, the webpage is located at www.loaded-designs.com/wuc . It is just a test page that I am developing, so please no criticism.
If you would like to see the souce php code, please contact me at ibanez270dx@aol.com
Any help is greatly appreciated!
Thank you,
- Jeff Miller
|
|
|
08-24-2005
|
#2 (permalink)
|
|
Recursively call who?
Join Date: Nov 2003
Location: Pittsburgh, PA
Posts: 294
|
If you could post the source code for the two pages it would make it a lot easier to help out with.
But anyway, I'd say to check back and make sure your list has a name attribute, so that the form has something to input the variable to. And probably check your method attribute on the form, make sure it corresponds to how you are pulling your information.
That's the best I can do, there are others here that are much better at PHP than me, so they can probably figure it out.
|
|
|
08-24-2005
|
#3 (permalink)
|
|
Invicible Snake
Join Date: Sep 2004
Location: Ho Chi Minh City,Vietnam
Posts: 668
|
i think the problem is your codes,try to use the ID instead of the "fullname" in your query.
Else,posting ur codes here is better,noone will take it without ur permission,trust me
__________________
|
|
|
08-25-2005
|
#4 (permalink)
|
|
Registered User
Join Date: Aug 2005
Posts: 15
|
thanks guys, here is the source code for the accounts.php and account_delete.php pages.... errr... at least the parts that matter:
ACCOUNTS.PHP
-------------------------
<?
$table_name = "auth_users";
include("dbfactors.inc");
$connection = mysql_connect("$host", "$db_user", "$db_password")
or die(mysql_error());
$db = @mysql_select_db($db_name, $connection) or die(mysql_error());
$sql = "SELECT fullname FROM $table_name ORDER BY fullname";
$result = @mysql_query($sql,$connection) or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
$fullname = stripslashes($row['fullname']);
$fullname = trim("$fullname");
$display_block .= "<option>$fullname</option>";
}
?>
...and the form part:
<form method="post" name="delete" action="account_delete.php">
<select name="delete" size="7" width="100" height="100">
<? echo "$display_block"; ?>
</select>
<input type="submit" value="delete" name="delete">
</form>
ACCOUNT_DELETE.PHP
------------------------------
<?
$table_name = "auth_users";
include("dbfactors.inc");
$connection = mysql_connect("$host", "$db_user", "$db_password")
or die(mysql_error());
$db = @mysql_select_db($db_name, $connection) or die(mysql_error());
$sql = "SELECT f_name, l_name, username, password, email, fullname, auth_type FROM $table_name WHERE fullname='$_POST[delete]'";
$result = @mysql_query($sql,$connection) or die(mysql_error());
?>
then all the insert things in the actual HTML part like... <? echo "$f_name"; ?> and stuff.
Hope this helps you help me!
Thanks guys,
- Jeff Miller
|
|
|
08-26-2005
|
#5 (permalink)
|
|
Registered User
Join Date: Aug 2005
Posts: 15
|
please guys?
|
|
|
08-28-2005
|
#6 (permalink)
|
|
Invicible Snake
Join Date: Sep 2004
Location: Ho Chi Minh City,Vietnam
Posts: 668
|
PHP Code:
$sql = "SELECT fullname FROM $table_name ORDER BY fullname";
$result = @mysql_query($sql,$connection) or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
$fullname = stripslashes($row['fullname']);
$fullname = trim("$fullname");
$display_block .= "<option>$fullname</option>";
Are you sure this work correctly?you should add the "echo $display_block; " to see if $display_block output all the name you need.
After that,i suggest you use the ID of the record instead of using $fullname,what if the fullname could be Xs."sd'+sdfk ,it sometimes could ruins ur codes,trust me,i met that problem one,now i only use ID for querrying.
After all the changes,if it wont work again,try to make a test by adding echo $_POST['delete'] at the beginning of ACCOUNT_DELETE.PHP to see if the ID is useable,if it appear and the code wont work,check ur SQL syntax.
-----------
Sorry for late,i`m busy these days
__________________
|
|
|
08-29-2005
|
#7 (permalink)
|
|
Registered User
Join Date: Aug 2005
Posts: 15
|
ok, so how would I give my users a number when they sign up for an account?
|
|
|
08-29-2005
|
#8 (permalink)
|
|
code anyone?
Join Date: Feb 2004
Location: New Zealand
Posts: 590
|
put a field on your users table called id, int type with 11 length, extra: auto_increment and PRIMARY checked and it will do it automatically
|
|
|
08-29-2005
|
#9 (permalink)
|
|
Registered User
Join Date: Aug 2005
Posts: 15
|
thanks for the id number thing!
However, my script still doesn't work! Everything looks perfect to me... but I dunno. Ok, so I changed around a few things. There is no longer a fullname column in the table, but there is an ID column with the auto_increment thing. That works fine. So, I tried to see what my selection box was sending by putting
<? echo "$_POST[delete]"; ?> on the account_delete.php page, and it turns out, its only sending the name "delete", which is the name of the select box. Heres the new and somewhat improved, but not yet correct code:
ACCOUNTS.PHP
----------------------------------
PHP Code:
<?
$table_name = "auth_users";
include("dbfactors.inc");
$connection = mysql_connect("$host", "$db_user", "$db_password")
or die(mysql_error());
$db = @mysql_select_db($db_name, $connection) or die(mysql_error());
$sql = "SELECT f_name, l_name, id FROM $table_name ORDER BY f_name";
$result = @mysql_query($sql,$connection) or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
$f_name = stripslashes($row['f_name']);
$l_name = stripslashes($row['l_name']);
$fullname = trim("$f_name $l_name");
$id = $row['id'];
$display_block .= "<option value=$id>$fullname</option>";
}
?>
and the html part...
<form method="post" action="account_delete.php">
<select name="delete" size="7" width="100" height="100">
<? echo "$display_block"; ?>
</select>
<input type="submit" value="delete" name="delete">
</form>
ACCOUNT_DELETE.PHP
-----------------------------
PHP Code:
<?
$table_name = "auth_users";
include("dbfactors.inc");
$connection = mysql_connect("$host", "$db_user", "$db_password")
or die(mysql_error());
$db = @mysql_select_db($db_name, $connection) or die(mysql_error());
$sql = "SELECT * FROM $table_name WHERE id = '$_POST[delete]'";
$result = @mysql_query($sql,$connection) or die(mysql_error());
$num= mysql_num_rows($result);
if ($num = 0) {
echo '<script>alert("That record has not been found in the database.");</script>';
echo '<script>history.back(1);</script>';
} else {
}
?>
and the html part is just.... <? echo "$username"; ?> and stuff
So I really don't know whats going on. Once again, I just think its sending the wrong variable to account_delete.php and I don't know why...
Thanks for you help!
- Jeff Miller
|
|
|
08-30-2005
|
#10 (permalink)
|
|
Registered User
Join Date: Aug 2005
Posts: 15
|
victory! I figured it out! However, I have another question. How do you get a password out of hash? Im my case I used the password() function to change the user's password into hash before adding it to the database. How do I go about going the opposite way so they can see their password in its original text?
Thank you!
|
|
|
08-30-2005
|
#11 (permalink)
|
|
Sheep Worrier
Join Date: Sep 2003
Location: Portsmouth, UK.
Posts: 4,105
|
Quote:
|
Originally Posted by ibanez270dx
victory! I figured it out! However, I have another question. How do you get a password out of hash? Im my case I used the password() function to change the user's password into hash before adding it to the database. How do I go about going the opposite way so they can see their password in its original text?
Thank you!
|
Unfortunately you can't! Password encryption is one way - if it worked in reverse it wouldn't be secure. You can compare hashes but you can't, unfortunately, do anything more than this. Now as far as I know anyway...
__________________
|
|
|
08-30-2005
|
#12 (permalink)
|
|
Recursively call who?
Join Date: Nov 2003
Location: Pittsburgh, PA
Posts: 294
|
I think M0g has it exact there. Not sure about it but I think the encoding is an md5 for php, but I'm not sure.
|
|
|
08-31-2005
|
#13 (permalink)
|
|
Invicible Snake
Join Date: Sep 2004
Location: Ho Chi Minh City,Vietnam
Posts: 668
|
if you can do it,Linux would be very suck out there 
Sorry ibane,i though you `ve known about ID,and the tut remind about that,so i leave it out from the beginning,finally u did it,good job
__________________
|
|
|
| Thread Tools |
|
|
| Display Modes |
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
|
|
|
All times are GMT +1. The time now is 05:59 PM. Content Relevant URLs by vBSEO 3.2.0
|