Ben5on Posted March 31, 2010 Share Posted March 31, 2010 I have searched these forums and i cant find what i need cause im new to PHP and all the stuff here is way over my head lol. Anyway thanks for looking at my post. Basically what i want to do is submit a username within a form on a HTML form and pass that value into a variable within a PHP file which works a few things out about that username. I then want it to redirect to another webpage where the variables from the PHP file can be used by using the <? echo $variable ?> command. I will now show you my code to see if you can spot the problem Heres the first page where the username will be submitted: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form action="phpfindingdetails.php" method="post" name="form"><input name="username" type="text" value="username" /></form> </body> </html> This is the PHP file used to work a few things out, basically what it does is grabs a certain string within the source code of an external webpage and stores it in a variable. It also works out the url for that users profile: <?php header("Location: /Untitled-4.html"); $name = $_POST['username']; $url = 'http://www.url.co.uk/home/'; $userprofile = $url.$name; $raw = file_get_contents($userprofile); $newlines = array('\t','\n','\r','\x20\x20','\0','\x0B'); $content = str_replace($newlines, '', html_entity_decode($raw)); //---------------------------------------------------------------- $mottostart = '<div class="profile-motto">'; $mottoend = '<div class="clear"></div>'; //----------------------------------------------------------------- function get_string_between($string, $start, $end){ $string = ' '.$string; $ini = strpos($string,$start); if ($ini == 0) return ''; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len); } //----------------------------------------------------------------- $motto = get_string_between($content, $mottostart, $mottoend); ?> This is the page which i want to use the variables from the previous PHP file, but it seems as if the PHP file hasn't been included properly. This page displays an iFrame of an external website within my HTML page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php include ("phpfindingdetails.php"); ?> <div style="overflow: hidden; width: 270px; height: 296px; position: relative;" id="i_div"> <iframe name="i_frame" src="http://www.url.co.uk/home/<? echo $userprofile ?>" style="border: 0pt none ; left: -630px; top: -158px; position: absolute; width: 1276px; height: 615px;" scrolling="no"></iframe></div> </body> </html>] Link to comment https://forums.phpfreaks.com/topic/197129-please-help/ Share on other sites More sharing options...
tomtimms Posted March 31, 2010 Share Posted March 31, 2010 On the page you want to have the username displayed you have to GET the variable from the form. You are using the POST method so you would need to do this. if (isset($_POST['username'])) { $username = $_POST['username']; } else { $username = ""; } now $username variable has a value that was passed from the form. hope this helps. Link to comment https://forums.phpfreaks.com/topic/197129-please-help/#findComment-1034784 Share on other sites More sharing options...
Jax2 Posted March 31, 2010 Share Posted March 31, 2010 quick question ... the last page you show that has the include phpfinddetails.php in it ... is that a .html file? .html files are not parsed for php ... so that won't work. Link to comment https://forums.phpfreaks.com/topic/197129-please-help/#findComment-1034785 Share on other sites More sharing options...
Jax2 Posted March 31, 2010 Share Posted March 31, 2010 On the page you want to have the username displayed you have to GET the variable from the form. You are using the POST method so you would need to do this. if (isset($_POST['username'])) { $username = $_POST['username']; } else { $username = ""; } now $username variable has a value that was passed from the form. hope this helps. Didn't he already do that? $name = $_POST['username']; in the phpfindingdetails.php page? Link to comment https://forums.phpfreaks.com/topic/197129-please-help/#findComment-1034786 Share on other sites More sharing options...
Ben5on Posted March 31, 2010 Author Share Posted March 31, 2010 The phpfindingdetails.php is the second piece of code i showed you in my post. Oh and thanks tomtimms ill try this out and get back to you right away EDIT: Yea that didnt work, anyone got any other ideas? Link to comment https://forums.phpfreaks.com/topic/197129-please-help/#findComment-1034787 Share on other sites More sharing options...
Jax2 Posted March 31, 2010 Share Posted March 31, 2010 The phpfinddetails.php is the second piece of code i showed you in my post. Oh and thanks tomtimms ill try this out and get back to you right away Right, I get that... what I was talking about was this piece: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php include ("phpfindingdetails.php"); ?> <div style="overflow: hidden; width: 270px; height: 296px; position: relative;" id="i_div"> <iframe name="i_frame" src="http://www.url.co.uk/home/<? echo $userprofile ?>" style="border: 0pt none ; left: -630px; top: -158px; position: absolute; width: 1276px; height: 615px;" scrolling="no"></iframe></div> </body> </html>] If that is a .html file, it won't recognize the <?php include ("phpfindingdetails.php"); ?> part. You have to tell your server to parse PHP code in .html files as well if you want to do that, otherwise the file will need to be a .php file. http://www.desilva.biz/php/phpinhtml.html Link to comment https://forums.phpfreaks.com/topic/197129-please-help/#findComment-1034790 Share on other sites More sharing options...
Ben5on Posted March 31, 2010 Author Share Posted March 31, 2010 Ahhh yea thats an HTML file, sorry for the miss interpretation. You can do that in the htaccess file cant you? Link to comment https://forums.phpfreaks.com/topic/197129-please-help/#findComment-1034794 Share on other sites More sharing options...
Jax2 Posted March 31, 2010 Share Posted March 31, 2010 Ahhh yea thats an HTML file, sorry for the miss interpretation. You can do that in the htaccess file cant you? Sure can, that link I provided tells you exactly what to put in your .htaccess ... Link to comment https://forums.phpfreaks.com/topic/197129-please-help/#findComment-1034795 Share on other sites More sharing options...
Ben5on Posted March 31, 2010 Author Share Posted March 31, 2010 Thanks man, unfortunatly i dont have access to that as my uncle is hosting my project. Ill ask him asap and get back to you. Thanks again, great help. Link to comment https://forums.phpfreaks.com/topic/197129-please-help/#findComment-1034797 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.