problem with $_post

Reply

Join Date: Nov 2007
Posts: 10
Reputation: bjg5858 is an unknown quantity at this point 
Solved Threads: 0
bjg5858 bjg5858 is offline Offline
Newbie Poster

problem with $_post

 
0
  #1
Jul 14th, 2009
I have a form which takes a string from a database and posts it to another page problem is that post seems to be shortening the variable.

So if post should be "product name" it is shortened to "product" by post I think.

Any help would be great thanks.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 172
Reputation: Menster is an unknown quantity at this point 
Solved Threads: 22
Menster's Avatar
Menster Menster is offline Offline
Junior Poster

Re: problem with $_post

 
0
  #2
Jul 15th, 2009
Hi there,
Is "product name" the name of the input box & post variable or is that the value of the variable/text in the input box?
$me = new Person();
if (isset($_COOKIE)){
$me->eat($_COOKIE);
} else { $me->starve(); }
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 10
Reputation: bjg5858 is an unknown quantity at this point 
Solved Threads: 0
bjg5858 bjg5858 is offline Offline
Newbie Poster

Re: problem with $_post

 
0
  #3
Jul 15th, 2009
Here is the real code "product name" was just an example.
This is the part of the input form;

HTML and CSS Syntax (Toggle Plain Text)
  1. echo "<select name='type'>";
  2. include("mysql_conn.php");
  3. include("db_conn.php");
  4.  
  5. // Get a specific result from the "type" table
  6. $result = mysql_query("SELECT * FROM type") or die(mysql_error());
  7.  
  8. while($row = mysql_fetch_array( $result )) {
  9. $type = $row['type'];
  10. echo "<option value=$type>$type</option>";
  11. }
  12. echo "</select>";
Here is a some code from the processing form which adds user input to the database;
HTML and CSS Syntax (Toggle Plain Text)
  1. $prod_type = $_POST['type'];
  2.  
  3. $qry = "INSERT INTO products(prod_name, prod_desc, prod_skincond, prod_application, prod_benefits, prod_type, prod_price, prod_img, prod_size, prod_code) VALUES('$prod_name','$prod_desc','$prod_skincond','$prod_application','$prod_benefits','$prod_type','$prod_price','$img','$prod_size','$prod_code')";
  4. $result = @mysql_query($qry);
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 172
Reputation: Menster is an unknown quantity at this point 
Solved Threads: 22
Menster's Avatar
Menster Menster is offline Offline
Junior Poster

Re: problem with $_post

 
0
  #4
Jul 15th, 2009
Originally Posted by bjg5858 View Post
HTML and CSS Syntax (Toggle Plain Text)
  1. echo "<select name='type'>";
  2. include("mysql_conn.php");
  3. include("db_conn.php");
  4.  
  5. // Get a specific result from the "type" table
  6. $result = mysql_query("SELECT * FROM type") or die(mysql_error());
  7.  
  8. while($row = mysql_fetch_array( $result )) {
  9. $type = $row['type'];
  10. echo "<option value=$type>$type</option>";
  11. }
  12. echo "</select>";
I think the problem might be here, try enclosing the value attribute for the select statement in quotes:
  1. while($row = mysql_fetch_array( $result )) {
  2. $type = $row['type'];
  3. echo "<option value=\"$type\">$type</option>";
  4. }

Another thing you can try is, on the page that you post this form to, at the top:
  1. echo "<pre>";
  2. print_r($_POST);
  3. echo "</pre>";
  4. die();
Which will tell exactly what is coming through from your form.
$me = new Person();
if (isset($_COOKIE)){
$me->eat($_COOKIE);
} else { $me->starve(); }
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 66
Reputation: kronikmedia is an unknown quantity at this point 
Solved Threads: 1
kronikmedia kronikmedia is offline Offline
Junior Poster in Training

Re: problem with $_post

 
0
  #5
Jul 15th, 2009
All variables have a limit on the legth of values it can hold. If you are using Joomla or another CMS then often restrictions are placed and you can only post values using the methods designated in the API.
Kronik Media: Web design Company in London, UK.

Our Websites:
Estate Agent Website
Search engine marketing & eCommerce Resources for business
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 10
Reputation: bjg5858 is an unknown quantity at this point 
Solved Threads: 0
bjg5858 bjg5858 is offline Offline
Newbie Poster

Re: problem with $_post

 
0
  #6
Jul 16th, 2009
Thanks Menster Adding the quotes fixed the problem.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 380 | Replies: 5
Thread Tools Search this Thread



Tag cloud for HTML and CSS
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC