EzwanAbid Posted December 20, 2012 Share Posted December 20, 2012 I'm trying to passing a data by url.. and what I want to know here, is it possible to insert php code inside <form action> ? Like this : <form id="form56" name="form56" class="wufoo topLabel page" autocomplete="off" enctype="multipart/form-data" method="post" novalidate action="<?php searchres.php?id=$id?>"> Or is there any better way that I can try? Hope someone can help me here. Link to comment https://forums.phpfreaks.com/topic/272214-can-i-use-php-code-inside-html-form-action/ Share on other sites More sharing options...
Christian F. Posted December 20, 2012 Share Posted December 20, 2012 I think you mean to do this: action="searchres.php?id=<?php echo $id; ?>"> PS: Remember to typecast the ID to an integer (by using (int)) when retrieving it from wherever, to ensure that no-one can put any HTML content into it and thus attack your users with an XSS (or similar). Link to comment https://forums.phpfreaks.com/topic/272214-can-i-use-php-code-inside-html-form-action/#findComment-1400574 Share on other sites More sharing options...
EzwanAbid Posted December 20, 2012 Author Share Posted December 20, 2012 wow Thank you Christian.. I never expect it was you again.. Thx it's working ! .. but I have another question here.. Can I use this code to call 2 field from my database into my html? mysql_query("SELECT adminfullname,department FROM admin WHERE id='$id'"); Those adminfullname and department will refer to the admin table where $id that I send by url just now. Link to comment https://forums.phpfreaks.com/topic/272214-can-i-use-php-code-inside-html-form-action/#findComment-1400575 Share on other sites More sharing options...
Christian F. Posted December 20, 2012 Share Posted December 20, 2012 Yes, I don't see any problems with it. Though, except the slight issue that integer values shouldn't be quoted in SQL queries. Assuming $id is an integer, and that you've properly type-cast it. You're welcome, btw. Link to comment https://forums.phpfreaks.com/topic/272214-can-i-use-php-code-inside-html-form-action/#findComment-1400581 Share on other sites More sharing options...
EzwanAbid Posted December 20, 2012 Author Share Posted December 20, 2012 Thank you very much for helping me all this time Christian... I really appreciate that I think that was the last question from me for now..because in 4 days I need to present my system to my lecturer as my Finalproject in Diploma IT-Sofware .. and hope they will like it .. Link to comment https://forums.phpfreaks.com/topic/272214-can-i-use-php-code-inside-html-form-action/#findComment-1400582 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.