| | |
Sanitize PHP hidden form values
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Sep 2009
Posts: 19
Reputation:
Solved Threads: 0
Hi all, I am new to PHP
Do I need to sanitize hidden data values in a form before carrying out the query on MySQL db.
If so can someone assist me in the correct format
The category_id is an INT and the make is a String.
$category_id=$_POST['category_id'];
$make=$_POST['make'];
Also do I need to sanitize the query also
$result = mysql_query("SELECT * FROM products WHERE products_make ='$make'");
If you require any additional ifo please let me know.
Thanks in advance
David
Do I need to sanitize hidden data values in a form before carrying out the query on MySQL db.
If so can someone assist me in the correct format
The category_id is an INT and the make is a String.
$category_id=$_POST['category_id'];
$make=$_POST['make'];
Also do I need to sanitize the query also
$result = mysql_query("SELECT * FROM products WHERE products_make ='$make'");
If you require any additional ifo please let me know.
Thanks in advance
David
Last edited by davidjennings; Sep 11th, 2009 at 6:22 am.
In future please use code tags as this is not your first post. Also the following code should do the trick:
php Syntax (Toggle Plain Text)
$category_id=mysql_real_escape_string(stripslashes($_POST['category_id'])); $make=mysql_real_escape_string(stripslashes($_POST['make'])); $result = mysql_query("SELECT * FROM products WHERE products_make ='$make'") or die(mysql_error()); //or $resultb = mysql_query("SELECT * FROM products WHERE products_make ='$make' AND id ='$category_id'") or die(mysql_error());
Try not to bump 10 year old threads as it can be really annoying.
http://syntax.cwarn23.net/
My favourite PC. - MacGyver Fan
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*` My favourite PC. - MacGyver Fan
•
•
Join Date: Sep 2009
Posts: 19
Reputation:
Solved Threads: 0
Hi
Thanks for the information
working fine
Thanks for the heads up on the rule and in the future I will add it to any further posts.
You mentioned my previous post which is not resolved, any ideas for a solution.
Thanks again
David
Thanks for the information
working fine
Thanks for the heads up on the
PHP Syntax (Toggle Plain Text)
****
You mentioned my previous post which is not resolved, any ideas for a solution.
Thanks again
David
•
•
•
•
In future please use code tags as this is not your first post. Also the following code should do the trick:
php Syntax (Toggle Plain Text)
$category_id=mysql_real_escape_string(stripslashes($_POST['category_id'])); $make=mysql_real_escape_string(stripslashes($_POST['make'])); $result = mysql_query("SELECT * FROM products WHERE products_make ='$make'") or die(mysql_error()); //or $resultb = mysql_query("SELECT * FROM products WHERE products_make ='$make' AND id ='$category_id'") or die(mysql_error());
•
•
•
•
You mentioned my previous post which is not resolved, any ideas for a solution.
Try not to bump 10 year old threads as it can be really annoying.
http://syntax.cwarn23.net/
My favourite PC. - MacGyver Fan
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*` My favourite PC. - MacGyver Fan
•
•
Join Date: Sep 2009
Posts: 19
Reputation:
Solved Threads: 0
Hi
This thread is solved and I will mark it accordingly
But do you have time to look at my previous thread
www.daniweb.co./forums/thread222004.html
Thanks in advance.
David
This thread is solved and I will mark it accordingly
But do you have time to look at my previous thread
www.daniweb.co./forums/thread222004.html
Thanks in advance.
David
![]() |
Similar Threads
- Rewriting .htaccess from a php file or form (PHP)
- Rather complicated PHP project for novice (PHP)
- problems with php web form (PHP)
- Insert form values to database and redirect to self with the values still present (PHP)
- PHP Contact Form Help (PHP)
- Fetching Form Values with ASP (ASP)
- PHP Quote form (PHP)
- Storing dynamic form values in Arrays for display & insert (PHP)
- php login form (PHP)
- php mail form - need to redirect to new page (PHP)
Other Threads in the PHP Forum
- Previous Thread: Need help to integrate Paypal API in Kubelance
- Next Thread: Cron job problem
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax alerts apache api array beginner binary broken cakephp checkbox class cms code convert cron curl database date directory display download dynamic echo email error file files folder form forms function functions google hack href htaccess html htmlspecialchars image include insert integration ip java javascript joomla limit link login loop mail menu methods mlm mod_rewrite multiple mysql network object oop overwrite parse paypal pdf php problem query radio random recursion redirect regex remote script search securephp server sessions sms soap source space sql structure syntax system table tutorial update upload url validation validator variable video web xml youtube






