$_REQUEST not working, please help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
php_new_guy_09
Forum Newbie
Posts: 12
Joined: Fri Sep 04, 2009 3:21 pm

$_REQUEST not working, please help

Post by php_new_guy_09 »

Hi guys, i have a php script that seems to be working fine when i insert normal values into line 7, 8, 10, 17 however, when i try to use $_REQUEST then nothing happens?

here is my code

Code: Select all

$address = "localhost";
$uname = "my username"; 
$pword = "my password"; 
$database="my database"; 
 
//Incoming Variables
$sender = $_REQUEST['sender'];
$content = $_REQUEST['content'];
 
$selectednums = $sender; //Set selected numbers to sender.
 
//DB Connect
mysql_connect($address,$uname,$pword) or die("Cannot connect to database"); //Connect to database, warn if cannot connect
mysql_select_db($database) or die("Cannot Select Database");
 
//Insert received message into recievedmsg table
$sql="INSERT INTO recievedmsg (sender, content) VALUES('$sender','$content')";
$result_sql = mysql_query($sql) or die("Cannot perform insert recievedmsg query"); //Error if cannot connect
am i doing something wrong?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: $_REQUEST not working, please help

Post by onion2k »

php_new_guy_09 wrote:am i doing something wrong?
Yes. You're using _REQUEST. Don't. It depends on the variable input order in PHP's configuration, therefore you can't trust it to be the same value between different configurations. Using _GET and _POST instead.

Also, a bigger problem, you're not escaping your input data. Your code is open to an SQL inject attack.
php_new_guy_09
Forum Newbie
Posts: 12
Joined: Fri Sep 04, 2009 3:21 pm

Re: $_REQUEST not working, please help

Post by php_new_guy_09 »

onion2k wrote:
php_new_guy_09 wrote:am i doing something wrong?
Also, a bigger problem, you're not escaping your input data. Your code is open to an SQL inject attack.
I tried GET, but it didnt work either, sorry what do you mean by the above. Im new to php
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: $_REQUEST not working, please help

Post by jackpf »

Try turning on error reporting.

And google SQL injection ;)
Post Reply