PDA

View Full Version : PHP Help



Johno
17-08-2006, 09:34 AM
Hey

Im having a few problems with PHP on my site. To view a page you would use ?view=requests or whatever the array is but when you add an action it doesnt work.

EG :
<form method='post' action='?view=requests&action=send'> - Doesnt Work

Any ideas?

+ Rep to all that help :)

EDIT : Im using the C4H system on techtuts but on the admin when you try to delete/respond, It doesnt work also. The url that comes up is http://www.visualhabbo.net/v1.php?view=cfhadmin. But then when you reply the URL that comes up is http://www.visualhabbo.net/v1.php?act=reply&id=6 I dont think that is right, Should it be http://www.visualhabbo.net/v1.php?view=cfhadmin&act=reply&id=6

speed-networks!
17-08-2006, 09:36 AM
<form method='post' action='send'>

try that not sure thoe

Splinter
17-08-2006, 09:48 AM
.. are you trying to make it process the form in the same file if so try..


action='<?php echo $_SERVER['PHP_SELF']; ?>?view=requests&action=send'


or It could be a problem with your form processor.

Johno
17-08-2006, 09:48 AM
@Nick : Already tried that, Doesnt work :(

Ill try that now splinter
EDIT : Nope, Didnt work :(

Eric30
17-08-2006, 09:48 AM
Can i see the actual page which it is not working?

Johno
17-08-2006, 09:50 AM
<?
ob_start(); # Allows Cookies
include("config.php"); # Includes Your Configuration File
if($logged[username] && $logged[level] == 5) # If Logged In AND Level 5
{
switch($_GET[act]) # Lets Us Use One Page For The Entire Admin Part
{
default: # The Default Page
$rquery = mysql_query("SELECT * FROM cfh ORDER BY id DESC"); # Queries The Call For Help Messages
while($m=mysql_fetch_array($rquery)) # Displays Them All In Order
echo("<b>Username Requiring Help:</b> $m[username]
<br>
<b>Category:</b> $m[category]
<br>
<b>Message:</b> $m[message]
<br>
<b>Options:</b> <a href=\"?act=reply&id=$m[id]\">Respond</a> || <a href=\"?act=delete&id=$m[id]\">Delete</a><br><br>"); # Admin Control Panel
break;
case 'delete': # The Part In URL
$cquery = mysql_query("SELECT * FROM cfh WHERE id = '$_GET[id]'"); # Queries The Call For Helps
$c=mysql_fetch_array($cquery); # Displays Them All In Order
$delete = mysql_query("DELETE FROM `cfh` WHERE id = '$_GET[id]'"); # Deletes The Message From The Table
echo("The call for help message has been deleted!"); # Shows Message
break;
case 'reply': # The Part In URL
$rquery = mysql_query("SELECT * FROM cfh ORDER BY id DESC"); # Queries The Call For Help Messages
while($m=mysql_fetch_array($rquery)) # Displays Them All In Order
if($_POST[alert]) { # If Form Has Been Submitted
$message = $_POST[message]; # Message Variable
$username = $_POST[username]; # Username Variable
mysql_query(" UPDATE `cfh` SET `alert` = '$message' WHERE `username` = '$username' "); # Adds The Alert Into The Table
echo ("Your alert has been sent."); # Shows Message
}else{ # The Form Hasnt Been Submitted Yet
echo("<form method=\"post\"><b>Send To:</b> <input type=\"text\" name=\"username\" value=\"$m[username]\" readonly><br>
<b>Alert:</b> <textarea name=\"message\"></textarea><br><br>
<input type=\"submit\" name=\"alert\" value=\"Alert User\"></form>"); # Shows Alert Form
break;
}
}
} else { # User Isn't Logged In Or Level 5
echo("You Are Not Logged In Or Level 5"); # Shows Message
}
?>

When you attempt to delete or reply the system just fails and returns you to the homepage

speed-networks!
17-08-2006, 09:57 AM
Hi,At lest i tryed

Johno
17-08-2006, 10:10 AM
Anybody else know how to fix this?

And cheesybob you got your rep :)

speed-networks!
17-08-2006, 10:21 AM
lol :P thanks:P

Jae
17-08-2006, 10:23 AM
<?
ob_start(); # Allows Cookies
include("config.php"); # Includes Your Configuration File
if($logged[username] && $logged[level] == 5) # If Logged In AND Level 5
{
switch($_GET[act]) # Lets Us Use One Page For The Entire Admin Part
{
default: # The Default Page
$rquery = mysql_query("SELECT * FROM cfh ORDER BY id DESC"); # Queries The Call For Help Messages
while($m=mysql_fetch_array($rquery)) # Displays Them All In Order
echo("<b>Username Requiring Help:</b> $m[username]
<br>
<b>Category:</b> $m[category]
<br>
<b>Message:</b> $m[message]
<br>
<b>Options:</b> <a href=\"?act=reply&id=$m[id]\">Respond</a> || <a href=\"?act=delete&id=$m[id]\">Delete</a><br><br>"); # Admin Control Panel
break;
case 'delete': # The Part In URL
$cquery = mysql_query("SELECT * FROM cfh WHERE id = '$_GET[id]'"); # Queries The Call For Helps
$c=mysql_fetch_array($cquery); # Displays Them All In Order
$delete = mysql_query("DELETE FROM `cfh` WHERE id = '$_GET[id]'"); # Deletes The Message From The Table
echo("The call for help message has been deleted!"); # Shows Message
break;
case 'reply': # The Part In URL
$rquery = mysql_query("SELECT * FROM cfh ORDER BY id DESC"); # Queries The Call For Help Messages
while($m=mysql_fetch_array($rquery)) # Displays Them All In Order
if($_POST[alert]) { # If Form Has Been Submitted
$message = $_POST[message]; # Message Variable
$username = $_POST[username]; # Username Variable
mysql_query(" UPDATE `cfh` SET `alert` = '$message' WHERE `username` = '$username' "); # Adds The Alert Into The Table
echo ("Your alert has been sent."); # Shows Message
}else{ # The Form Hasnt Been Submitted Yet
echo("<form method=\"post\"><b>Send To:</b> <input type=\"text\" name=\"username\" value=\"$m[username]\" readonly><br>
<b>Alert:</b> <textarea name=\"message\"></textarea><br><br>
<input type=\"submit\" name=\"alert\" value=\"Alert User\"></form>"); # Shows Alert Form
break;
}
}
} else { # User Isn't Logged In Or Level 5
echo("You Are Not Logged In Or Level 5"); # Shows Message
}
?>

When you attempt to delete or reply the system just fails and returns you to the homepage

Don't you need // for comments :P

Sygon.
17-08-2006, 10:51 AM
Don't you need // for comments :P

3 comments :P




# hi

/* Hi */

// Hi



Also instead of
$_GET['act'] Should be
$_GET['action']

I think :S

1
17-08-2006, 11:01 AM
Have you saved it as .php and not .htm?

Johno
17-08-2006, 11:19 AM
Yes, It is saved as .php.

Its when a page has an action it just stops working

1
17-08-2006, 11:30 AM
Does your hosting support php?

Johno
17-08-2006, 11:32 AM
Yes, Everything else that is PHP works. Its the actions. Its all arrays and so on.

Want to hide these adverts? Register an account for free!