devouk Posted April 27, 2009 Share Posted April 27, 2009 Hi all Looking for a bit advice on the following The original idea was a demo site that was created for us on a new look website, but the company seems a bit reluctant to put in to a cms and also do the changes.. but one thing they have done which demistifises me and any google searching i been doing the following days Basically they have a "start an enquiry" form on each page. The form has name, phone, product query, and area This then is posted via a "post" to an enquiry.php page which is a full form and the values are populated with new extra fields and a captucha. I looked at the html and the javascript and there is nothing there so i presume they have done it with php. Now the enquiry page is its own entity .. ie no values passed and thus all fields are empty ie value="" i even tried to see if i "start an enquiry" if it echo the code thus i would be able to see this in the html which it doesnt. can someone point me in the direction of how to do this. is it done with php and dom which i havent really got a clue http://www.crearesites.co.uk/bradrail I find this a usefull feature but seems rarely discussed and wish to be enlightened. Many thanks Quote Link to comment https://forums.phpfreaks.com/topic/155909-how-do-they-do-this/ Share on other sites More sharing options...
DarkWater Posted April 27, 2009 Share Posted April 27, 2009 This is basic PHP form handling. Are you familiar with PHP at all, or are you just curious as to how they did this? ??? Basically, when the data get passed along to enquiry.php, they are put into the $_POST array. They can then use this array to populate the form fields. Quote Link to comment https://forums.phpfreaks.com/topic/155909-how-do-they-do-this/#findComment-820730 Share on other sites More sharing options...
devouk Posted April 27, 2009 Author Share Posted April 27, 2009 Hi Darkwater Thanks for the fast reply.. yeah i know basic php.. and i understand that the "post" send its an array .. but it was how i take the items from the array and push them from a variable back in to the form elements of textboxes off the new form.. without compromising the form if accessed without the post parameters can you tell me the best way of doing this ? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/155909-how-do-they-do-this/#findComment-820758 Share on other sites More sharing options...
DarkWater Posted April 27, 2009 Share Posted April 27, 2009 Well, since the value of a text input can be set with the value="" parameter, this works: <?php //assume you took care of sanitizing POST and all sorts of stuff up here printf('<input type="text" name="address" value="%s" />', (isset($_POST['address']) ? $_POST['address'] : '')); Quote Link to comment https://forums.phpfreaks.com/topic/155909-how-do-they-do-this/#findComment-820762 Share on other sites More sharing options...
devouk Posted April 28, 2009 Author Share Posted April 28, 2009 thanks darkwater.. you pointer me in the right direction and then played with what you gave and refined it to the point where i need to do a bit of error checking... it seems so easy what i did <?php $name=$post['name']; ?> <form method="post" action="processed.php"> <p>Name<input name="name" value="<?php print($name) ?>" type="text" class="formstyle" size="25" maxlength="50" style="width: 160px;" /> <br/> </form> I am greatefull for you bearing with me for a php fixer rather than programmer. ! Quote Link to comment https://forums.phpfreaks.com/topic/155909-how-do-they-do-this/#findComment-820780 Share on other sites More sharing options...
DarkWater Posted April 28, 2009 Share Posted April 28, 2009 What's the error? Quote Link to comment https://forums.phpfreaks.com/topic/155909-how-do-they-do-this/#findComment-820791 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.