![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
GFY's Halfpint
Industry Role:
Join Date: Jun 2007
Location: UK
Posts: 15,223
|
PHP help anybody..please
I have edited this preferences.php file and added two extra forms so that players can add both an avatar and a banner but the problem is when you add an avatar or sig and you already have a banner it takes the banner and quote away and vice versa. This is driving me crazy been trying to figure it out for the last 6 hours..lol
Does anybody know how to make these work independently of each other so that when you submit a new banner or avatar they do not affect each other..any help will be much appreciated Code:
<? include 'header.php'; if (isset($_POST['submit'])) { $avatar = $_POST["avatar"]; $quote = $_POST["quote"]; $banner = $_POST["banner"]; $sig = $_POST["sig"]; //insert the values if (!isset($message)){ $result= mysql_query("UPDATE `grpgusers` SET `avatar`='".$avatar."', `quote`='".$quote."' WHERE `id`='".$user_class->id."'"); $result= mysql_query("UPDATE `grpgusers` SET `banner`='".$banner."', `sig`='".$sig."' WHERE `id`='".$user_class->id."'"); echo Message('Your preferences have been saved.'); die(); } } ?> <? if (isset($message)) { echo Message($message); } ?> <tr><td class="contenthead"> Account Preferences </td></tr> <tr><td class="contentcontent"> <form name='login' method='post'> <table width='50%' border='0' align='center' cellpadding='0' cellspacing='0'> <tr> <td height='28'><font size='2' face='verdana'>Avatar Image Location </font></td> <td><font size='2' face='verdana'> <input type='text' name='avatar' value='<?= $user_class->avatar ?>'> </font></td> </tr> <tr> <tr> <td height='28' align="right"><font size='2' face='verdana'>Quote </font></td> <td><font size='2' face='verdana'> <input type='text' name='quote' value='<?= $user_class->quote ?>'> </font></td> </tr> <td> </td> <td><font size='2' face='verdana'> <input type='submit' name='submit' value='Save Preferences'> </font></td> </tr> </table> </form> <br> <tr><td class="contenthead"> Add Banner </td></tr> <tr><td class="contentcontent"> <form name='login' method='post'> <table width='100%' border='0' align='center' cellpadding='0' cellspacing='0'> <tr> <td height='28'><font size='2' face='verdana'>Banner Image Location </font></td> <td><font size='2' face='verdana'> <input type='text' name='banner' value='<?= $user_class->banner ?>'> </font></td> </tr> <tr> <tr> <td height='28' align="right"><font size='2' face='verdana'>Quote </font></td> <td><font size='2' face='verdana'> <input type='text' name='sig' value='<?= $user_class->sig ?>'> </font></td> </tr> <td> </td> <td><font size='2' face='verdana'> <input type='submit' name='submit' value='Save Preferences'> </font></td> </tr> </table> </form> <? include 'footer.php'; ?> |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
Join Date: May 2005
Posts: 2,737
|
Nothing is more awesome than code being mixed with layout.
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Confirmed User
Join Date: Jan 2003
Location: LA
Posts: 502
|
This is what causes the prob:
Code:
if (!isset($message)){ $result= mysql_query("UPDATE `grpgusers` SET `avatar`='".$avatar."', `quote`='".$quote."' WHERE `id`='".$user_class->id."'"); $result= mysql_query("UPDATE `grpgusers` SET `banner`='".$banner."', `sig`='".$sig."' WHERE `id`='".$user_class->id."'"); echo Message('Your preferences have been saved.'); die(); } |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
GFY's Halfpint
Industry Role:
Join Date: Jun 2007
Location: UK
Posts: 15,223
|
yeah.. we bought this script and it had it also had html code mixed with php
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 | |
GFY's Halfpint
Industry Role:
Join Date: Jun 2007
Location: UK
Posts: 15,223
|
Quote:
Im not a php coder and only know bits and bobs so if I change it to this will it work Code:
$result= mysql_query("UPDATE `grpgusers` SET `avatar`='".$avatar."', `quote`='".$quote."'`banner`='".$banner."', `sig`='".$sig."' WHERE `id`='".$user_class->id."'"); |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 | |
Confirmed User
Join Date: Jan 2003
Location: LA
Posts: 502
|
Quote:
Code:
if (isset(_POST['avatar'])) { $result = ...... } if (isset(_POST['banner'])) { $result = ...... } |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
GFY's Halfpint
Industry Role:
Join Date: Jun 2007
Location: UK
Posts: 15,223
|
Ok thanks I will give it a try... appreciate your help thanks
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
GFY's Halfpint
Industry Role:
Join Date: Jun 2007
Location: UK
Posts: 15,223
|
Is this the correct way to wrap the if (isset(_POST['avatar'])) { $result = ...... }
Code:
<? include 'header.php'; if (isset($_POST['submit'])) { if (isset($_POST['avatar'])){ $result = mysql_query("UPDATE `grpgusers` SET `avatar`='".$avatar."', WHERE `id`='".$user_class->id."'"); } if (isset($_POST['quote'])){ $result = mysql_query("UPDATE `grpgusers` SET `quote`='".$quote."', WHERE `id`='".$user_class->id."'"); } if (isset($_POST['banner'])){ $result = mysql_query("UPDATE `grpgusers` SET `banner`='".$banner."', WHERE `id`='".$user_class->id."'"); } if (isset($_POST['sig'])){ $result = mysql_query("UPDATE `grpgusers` SET `sig`='".$sig."', WHERE `id`='".$user_class->id."'"); } //insert the values echo Message('Your preferences have been saved.'); die(); |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 |
Confirmed User
Join Date: Aug 2007
Posts: 128
|
The most logical way:
Code:
<? include 'header.php'; if($_POST['form_type'] == 'avatarquote') { $avatar = $_POST["avatar"]; $quote = $_POST["quote"]; $result= mysql_query("UPDATE `grpgusers` SET `avatar`='".$avatar."', `quote`='".$quote."' WHERE `id`='".$user_class->id."'"); echo 'Your preferences have been saved.'; die(); } elseif($_POST['form_type'] == 'bannersig') { $banner = $_POST["banner"]; $sig = $_POST["sig"]; $result= mysql_query("UPDATE `grpgusers` SET `banner`='".$banner."', `sig`='".$sig."' WHERE `id`='".$user_class->id."'"); echo 'Your preferences have been saved.'; die(); } ?> <tr><td class="contenthead"> Account Preferences </td></tr> <tr><td class="contentcontent"> <form name='login' method='post'> <input type="hidden" name="form_type" value="avatarquote" /> <table width='50%' border='0' align='center' cellpadding='0' cellspacing='0'> <tr> <td height='28'><font size='2' face='verdana'>Avatar Image Location </font></td> <td><font size='2' face='verdana'> <input type='text' name='avatar' value='<?= $user_class->avatar ?>'> </font></td> </tr> <tr> <tr> <td height='28' align="right"><font size='2' face='verdana'>Quote </font></td> <td><font size='2' face='verdana'> <input type='text' name='quote' value='<?= $user_class->quote ?>'> </font></td> </tr> <td> </td> <td><font size='2' face='verdana'> <input type='submit' name='submit' value='Save Preferences'> </font></td> </tr> </table> </form> <br> <tr><td class="contenthead"> Add Banner </td></tr> <tr><td class="contentcontent"> <form name='login' method='post'> <input type="hidden" name="form_type" value="bannersig" /> <table width='100%' border='0' align='center' cellpadding='0' cellspacing='0'> <tr> <td height='28'><font size='2' face='verdana'>Banner Image Location </font></td> <td><font size='2' face='verdana'> <input type='text' name='banner' value='<?= $user_class->banner ?>'> </font></td> </tr> <tr> <tr> <td height='28' align="right"><font size='2' face='verdana'>Quote </font></td> <td><font size='2' face='verdana'> <input type='text' name='sig' value='<?= $user_class->sig ?>'> </font></td> </tr> <td> </td> <td><font size='2' face='verdana'> <input type='submit' name='submit' value='Save Preferences'> </font></td> </tr> </table> </form> <? include 'footer.php'; ?>
__________________
230-699 |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#10 |
Registered User
Join Date: Nov 2006
Posts: 11
|
Code:
$avatar = blah blah $quote = blah Blah mysql_query(UPDATE 'whatever' SET avatar = $avatar, quote = $quote and so on ... WHERE id = id ..) Also teh script is a drama .. because you allow teh users to put everything in your database without any checking .. at least do a mysql escape on the posted vars.
__________________
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#11 |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,111
|
A better solution would probably be to just run one form instead of 2. That way your vars are always filled out on the submit and it doesn't matter if your rewrite them each time.
Code:
<? include 'header.php'; if (isset($_POST['submit'])) { $avatar = $_POST["avatar"]; $quote = $_POST["quote"]; $banner = $_POST["banner"]; $sig = $_POST["sig"]; //insert the values if (!isset($message)){ // kill this write and include it in the next // $result= mysql_query("UPDATE `grpgusers` SET `avatar`='".$avatar."', `quote`='".$quote."' WHERE `id`='".$user_class->id."'"); $result= mysql_query("UPDATE `grpgusers` SET `banner`='".$banner."', `sig`='".$sig."', avatar`='".$avatar."', `quote`='".$quote."'WHERE `id`='".$user_class->id."'"); echo Message('Your preferences have been saved.'); die(); } } ?> <? if (isset($message)) { echo Message($message); } ?> <tr><td class="contenthead"> Account Preferences </td></tr> <tr><td class="contentcontent"> <form name='login' method='post'> <table width='50%' border='0' align='center' cellpadding='0' cellspacing='0'> <tr> <td height='28'><font size='2' face='verdana'>Avatar Image Location </font></td> <td><font size='2' face='verdana'> <input type='text' name='avatar' value='<?= $user_class->avatar ?>'> </font></td> </tr> <tr> <tr> <td height='28' align="right"><font size='2' face='verdana'>Quote </font></td> <td><font size='2' face='verdana'> <input type='text' name='quote' value='<?= $user_class->quote ?>'> </font></td> </tr> <td> </td> <td><font size='2' face='verdana'> // kill this submit button here... <!-- <input type='submit' name='submit' value='Save Preferences'> --> </font></td> </tr> </table> </form> <br> <tr><td class="contenthead"> Add Banner </td></tr> <tr><td class="contentcontent"> // kill this form line <!-- <form name='login' method='post'> --> <table width='100%' border='0' align='center' cellpadding='0' cellspacing='0'> <tr> <td height='28'><font size='2' face='verdana'>Banner Image Location </font></td> <td><font size='2' face='verdana'> <input type='text' name='banner' value='<?= $user_class->banner ?>'> </font></td> </tr> <tr> <tr> <td height='28' align="right"><font size='2' face='verdana'>Quote </font></td> <td><font size='2' face='verdana'> <input type='text' name='sig' value='<?= $user_class->sig ?>'> </font></td> </tr> <td> </td> <td><font size='2' face='verdana'> <input type='submit' name='submit' value='Save Preferences'> </font></td> </tr> </table> </form> <? include 'footer.php'; ?>
__________________
All cookies cleared! |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#12 |
Confirmed User
Join Date: Sep 2004
Location: In front of computer
Posts: 564
|
Code:
<? include 'header.php'; //Add these lines to ensure you don't get hacked $_POST = trim(array_map('mysql_real_escape_string', $_POST)); $_GET = trim(array_map('mysql_real_escape_string', $_GET)); $_COOKIE = trim(array_map('mysql_real_escape_string', $_COOKIE)); ?>
__________________
"The object of war is not to die for your country but to make the other bastard die for his." -Patton "Only the dead have seen the end of war." -Plato |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#13 | |
GFY's Halfpint
Industry Role:
Join Date: Jun 2007
Location: UK
Posts: 15,223
|
Quote:
The script has been a pain in the arse ever since we purchased it and the guy that scripted it has given us no support what so ever. We ended up having to pay another coder for a load of bug fixes in the end..but thats life and nothing is ever easy..lol Thanks for all your help guys |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#14 | |
GFY's Halfpint
Industry Role:
Join Date: Jun 2007
Location: UK
Posts: 15,223
|
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#15 |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,111
|
You should put those right after the include header or if your header uses any POST statements, then put it before the include header.
__________________
All cookies cleared! |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#16 | |
GFY's Halfpint
Industry Role:
Join Date: Jun 2007
Location: UK
Posts: 15,223
|
Quote:
![]() |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#17 |
GFY's Halfpint
Industry Role:
Join Date: Jun 2007
Location: UK
Posts: 15,223
|
Finally got it working thanks to all of you
![]() A big thanks to PornGeneral for your help and the links ![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#18 |
Confirmed User
Join Date: Dec 2007
Location: Chatsworth, CA
Posts: 1,964
|
What about PHP mixed with SQL, mixed with Javascript, mixed with malformed HTML?
|
![]() |
![]() ![]() ![]() ![]() ![]() |