|
Posted by Jochem Maas on 03/04/05 00:17
p80 wrote:
> any idea why this simple peace of code is not working?
now lets see:
1. <?php
2. // code that will be executed if the form has been submitted:
3. $submit_post=$_REQUEST['submit'];
4.
5. if ($submit_post=='yes') {
$submit_post will never equal 'yes' because your submit buttons value is
'submit' and its name is also 'submit', the POST value is are overwriting
the GET value (thats default order for php anyway)
removing the name attribute of the submit button should do the trick.
6.
7. // connect to the database
8. // (you may have to adjust the hostname,username or password)
9.
10. include "db.php";
11.
12.
13. $result=MYSQL_QUERY("INSERT INTO machines
14. (description_fr) ".
15. "VALUES ('$form_description_en')");
you might want to sanitize $form_description_en before sticking it in your
query like that. see http://php.net/mysql_escape_string
16. $bob = $img->image_name;
who is bob... why are you trying to get the property of
a non-existent object? php will have a fatal one on this.
17.
18. #$thumbdata = addslashes(fread(fopen('.thumb/$bob', "r")));
19.
20.
21.
22.
23. $id= mysql_insert_id();
24.
25. print "query success!";
26. echo "$form_description_en";
the quotes around the var above are a waste of cpu.
the following will do:
echo $form_description_en;
27. MYSQL_CLOSE();
28.
29. }
30.
31.
32. ?>
33.
34. <form method="post" action="test.php?submit=yes" enctype="multipart/form-data" />
35. Description:<br />
36. <textarea name="form_description_en" id="form_description_en" rows="4" cols="40"></textarea><br />
37.
38. <p><input type="submit" name="submit" value="submit" /> </p>
39.
40. </form>
>
> http://hashphp.org/pastebin?pid=1880
>
> thanx in advance
>
Navigation:
[Reply to this message]
|