killsite Posted January 22, 2008 Share Posted January 22, 2008 I work in a callcenter where we're required to log notes in a specific format. I want to have a page that if I fill in a text box labeled "Callers name:" then after I hit submit, shows on the other page "Callers name: Joe Schmo".. Can someone please point me in the right direction on how i would pass the post data to another page using php or where I can find a template that'll accomplish this.. I've searched php.resourceindex.com and hotscripts.com but either I'm not searching right or there are none already pre-developed for me to upload, customize, and use. ??? Quote Link to comment Share on other sites More sharing options...
interpim Posted January 23, 2008 Share Posted January 23, 2008 first you have to build your form... which is simple html, but for the action you want to put the script that will display the next page... for instance say your first page is form.php, you'll have your form code, and it is submitting to display.php form code <form action='display.php' method='post'> <input type='text' name='name'><br> <input type='submit' value='submit'> </form> your display.php will get the data submitted and display it... <?php $name = $_POST['name']; echo $name; ?> Quote Link to comment Share on other sites More sharing options...
killsite Posted January 23, 2008 Author Share Posted January 23, 2008 Thanks interpim, yours worked nice.. Before you sent me that, I found another and was testing.. It would redirect to the php script but it was empty/blank. This is what I used: <html> <form method="post" action="verified.php"> Caller Name:<input type="text" name="first_name0"/><br/> <input type="submit" name="submit"/> </form> </html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>New Page 1</title> </head> <body> Caller Name: <?php $first_name0 = $_POST['first_name0']; ?> </body> </html> I got this info from http://mrarrowhead.com/php_tutorials_mah/php_passing_variables.php and I think I'm getting it now. Mines failed because I passed the variable but told it to do nothing, if I added "echo $first_name0;" in the next line it would've worked. Did I get that right? Quote Link to comment Share on other sites More sharing options...
interpim Posted January 23, 2008 Share Posted January 23, 2008 that is correct... with the second page code you have all it does is assign the value entered from your form into the variable $first_name0 Quote Link to comment Share on other sites More sharing options...
killsite Posted January 24, 2008 Author Share Posted January 24, 2008 Now i have another problem. Same form, same method noted above but when the form spits out the text, all " ' " characters are outputted with " \' " instead. Could somebody help me out with this.. Here's an example: Can't , Won't , Don't ......................... Can\'t , Won\'t , Don\'t I hope this is allowed but if you want to go to the test script, it's at: http://4phpfreaks.freehostia.com/caller1.html None of the fields are required so to replicate, just use submit anyone of the boxes. Makes me wonder what other characters would have to be cleaned up. Anyhow, any help would be appreciated. Quote Link to comment Share on other sites More sharing options...
Stooney Posted January 24, 2008 Share Posted January 24, 2008 Use stripslashes() on your variables. example: $var="Can\'t , Won\'t , Don\'t"; $var=stripslashes($var); echo $var; Quote Link to comment Share on other sites More sharing options...
killsite Posted January 24, 2008 Author Share Posted January 24, 2008 Changed my code accordingly, but it doesn't work... <?php $name = $_POST['needed']; $var="Can\'t , Won\'t , Don\'t"; $var=stripslashes($var); echo $needed; ?> The output I get still shows: Can\'t , Won\'t , Don\'t Furthermore, I want it keep return characters submitted in the form as well. Example: Typing in the following in the form.. Customer Info line 1 Customer Info line 2 Customer Info line 3 Customer Info line 4 Produces: Customer Info line 1 Customer Info line 2 Customer Info line 3 Customer Info line 4 As with these, I'm looking for something to work globally in php or some other method where my script takes the output, then formats it exactly as it was inputted. It shouldn't include ' \ ' when apostrophes are being used and return values should stick. If I could tell php to use the html br tag when returns are found that would be awsome, but it's obvious it isn't being passed from the form. I found this somewhere on the net and tried to use it in the head of both of either of the pages but it didn't work. I know it's java but it looks like it's using what would be supported in php "\n". Correct me if I'm wrong, because I thought I seen it posted somewhere else on the net. Here's the code.. <script type="text/javascript"> // handy proto method String.prototype.trim = function() { return this.replace(/(^\s+)¦\s+$/g,"")} function reply(number) { number = number.trim() // remove lead + trail spaces if(!number) return // if empty string, stop var area = document.comment.commenttext var addition = "[reply" + number + "] \n"; area.value += addition; area.focus(); } </script> Does anybody have a solution for this or know of a post I can review where this was discussed. I did try searching this forum but couldn't find the answer. Probably using the wrong search terms so any help or a point in the right direction would be appreciated. Thanks. Quote Link to comment Share on other sites More sharing options...
killsite Posted January 24, 2008 Author Share Posted January 24, 2008 crhisd or int, do any of you guys have any suggestions for me? Quote Link to comment Share on other sites More sharing options...
Zhadus Posted January 24, 2008 Share Posted January 24, 2008 Changed my code accordingly, but it doesn't work... <?php $name = $_POST['needed']; $var="Can\'t , Won\'t , Don\'t"; $var=stripslashes($var); echo $needed; ?> The correct code would be <?php $name = $_POST['needed']; $var="Can\'t , Won\'t , Don\'t"; $var=stripslashes($var); echo $var; ?> In order to auto format, you can just load the variable and strip at the same time. Just do $name = stripslashes($_POST['needed']); echo $name; For your display on multiple lines, a quick way to do it(as long as normal formatting isn't that important). You can load it into the same type of field you posted it as. For instance if you are using a textarea, your first page would look like this: <form action=page2.php method=post> <textarea cols=30 rows=30 name=tbox></textarea> <input type="submit" value="Submit"> </form> And in the second page you would put it into another textarea with readonly set, so it can't be changed: <?php $text = stripslashes($_POST['tbox']); echo "<textarea cols=30 rows=30 readonly=yes>" . $text . "</textarea>"; ?> Hope that helps, I think everyone else got frustrated echo " Quote Link to comment Share on other sites More sharing options...
Stooney Posted January 24, 2008 Share Posted January 24, 2008 For retaining line breaks, you can use n2lbr(). It will replace line breaks with 'br' tags. An alternative to this would be outputting it with 'pre' tags. echo n2lbr($var); or echo '<pre>'.$var.'</pre>'; Quote Link to comment Share on other sites More sharing options...
killsite Posted January 26, 2008 Author Share Posted January 26, 2008 using the stripslashes and pre tags worked. Thanks much. Quote Link to comment Share on other sites More sharing options...
smorgan0024 Posted March 14, 2008 Share Posted March 14, 2008 Yes, just use echo. Quote Link to comment 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.