hilda Posted December 9, 2008 Share Posted December 9, 2008 I am trying to use a echo statement and push out a link. I am not sure how to do this but I figured I would post on here and ask. <?PHP $filename = "file.txt"; #Must CHMOD to 666 $text = $_POST['action']; # Form must use POST. if it uses GET, use the line below: #$text = $_GET['theformfieldname']; #POST is the preferred method $fp = fopen ($filename, "w"); # w = write to the file only, create file if it does not exist, discard existing contents if ($fp) { fwrite ($fp, $text); stripslashes($text); fclose ($fp); echo ("I would like to put an HTML Page or code in here." ); } else { echo ("I would like to put an HTML Page or code in here"); } ?> Any help would great. Quote Link to comment https://forums.phpfreaks.com/topic/136267-echo/ Share on other sites More sharing options...
DarkWater Posted December 9, 2008 Share Posted December 9, 2008 I don't quite get what you're asking. =P Quote Link to comment https://forums.phpfreaks.com/topic/136267-echo/#findComment-710851 Share on other sites More sharing options...
amclean Posted December 9, 2008 Share Posted December 9, 2008 If you're talking about uploading a file and naming it, then outputting the file as a link, then you would have to output the path you copied the file to to an "<a href='path'>[Link]</a tag. Should be as simple as that. Quote Link to comment https://forums.phpfreaks.com/topic/136267-echo/#findComment-710872 Share on other sites More sharing options...
hilda Posted December 9, 2008 Author Share Posted December 9, 2008 No as of now after it writes to that txt file it echos says "thank you blah blah" I want it to either bring me to another page or echo out a link to click back etc... Is that possible? Quote Link to comment https://forums.phpfreaks.com/topic/136267-echo/#findComment-710889 Share on other sites More sharing options...
flyhoney Posted December 9, 2008 Share Posted December 9, 2008 Use header() to redirect. header('Location http://www.example.com/otherpage.php'); [/php Quote Link to comment https://forums.phpfreaks.com/topic/136267-echo/#findComment-710890 Share on other sites More sharing options...
hilda Posted December 10, 2008 Author Share Posted December 10, 2008 Sorry but do i use that in the echo statement or in it's place? Quote Link to comment https://forums.phpfreaks.com/topic/136267-echo/#findComment-711488 Share on other sites More sharing options...
darkfreaks Posted December 10, 2008 Share Posted December 10, 2008 you can create a file called thankyou.html have it display a message, then have the PHP code redirect there Quote Link to comment https://forums.phpfreaks.com/topic/136267-echo/#findComment-711548 Share on other sites More sharing options...
hilda Posted December 10, 2008 Author Share Posted December 10, 2008 I understand but within the echo code. I tried that an it only displayed the link. I am not sure how to get the page to redirect to that? Quote Link to comment https://forums.phpfreaks.com/topic/136267-echo/#findComment-711564 Share on other sites More sharing options...
justinh Posted December 10, 2008 Share Posted December 10, 2008 <?PHP $filename = "file.txt"; #Must CHMOD to 666 $text = $_POST['action']; # Form must use POST. if it uses GET, use the line below: #$text = $_GET['theformfieldname']; #POST is the preferred method $fp = fopen ($filename, "w"); # w = write to the file only, create file if it does not exist, discard existing contents if ($fp) { fwrite ($fp, $text); stripslashes($text); fclose ($fp); header('Location http://www.example.com/otherpage.php'); } else { header('Location http://www.example.com/otherpage2.php'); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/136267-echo/#findComment-711566 Share on other sites More sharing options...
premiso Posted December 10, 2008 Share Posted December 10, 2008 <?php $filename = "file.txt"; #Must CHMOD to 666 $text = $_POST['action']; # Form must use POST. if it uses GET, use the line below: #$text = $_GET['theformfieldname']; #POST is the preferred method $fp = fopen ($filename, "w"); # w = write to the file only, create file if it does not exist, discard existing contents if ($fp) { fwrite ($fp, $text); stripslashes($text); fclose ($fp); header('Location http://www.example.com/otherotherpage.php'); } else { header('Location http://www.example.com/otherpage.php'); } ?> Not within the echo, replace the echo code with it. Quote Link to comment https://forums.phpfreaks.com/topic/136267-echo/#findComment-711567 Share on other sites More sharing options...
Andy-H Posted December 10, 2008 Share Posted December 10, 2008 Why are you usinf stripslashes after the fwrite() function? Quote Link to comment https://forums.phpfreaks.com/topic/136267-echo/#findComment-711571 Share on other sites More sharing options...
hilda Posted December 10, 2008 Author Share Posted December 10, 2008 Ok so i used the code below and still no dice. It uploads the data but wont redirect me to that page. Not sure what is the issue but I do know it's driving me nuts ??? I have tried to do some research before bothering your all but I am at a stand still. Any help would be great. <?php $filename = "file.txt"; #Must CHMOD to 666 $text = $_POST['action']; # Form must use POST. if it uses GET, use the line below: #$text = $_GET['theformfieldname']; #POST is the preferred method $fp = fopen ($filename, "w"); # w = write to the file only, create file if it does not exist, discard existing contents if ($fp) { fwrite ($fp, $text); fclose ($fp); header('Location http://www.example.com/otherotherpage.php'); } else { header('Location http://www.example.com/otherpage.php'); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/136267-echo/#findComment-711670 Share on other sites More sharing options...
gevans Posted December 10, 2008 Share Posted December 10, 2008 Please tell me that you changed http://www.example.com/otherpage.php to what you wanted!!?? Quote Link to comment https://forums.phpfreaks.com/topic/136267-echo/#findComment-711673 Share on other sites More sharing options...
revraz Posted December 10, 2008 Share Posted December 10, 2008 It should be header('Location: http://www.example.com/otherotherpage.php'); missing the colon. Quote Link to comment https://forums.phpfreaks.com/topic/136267-echo/#findComment-711675 Share on other sites More sharing options...
hilda Posted December 10, 2008 Author Share Posted December 10, 2008 LOL Yes I did change it to the location that I wanted. I know the page is live as well. i can go directly to it. Quote Link to comment https://forums.phpfreaks.com/topic/136267-echo/#findComment-711683 Share on other sites More sharing options...
gevans Posted December 10, 2008 Share Posted December 10, 2008 Awsome!! in which case check out revraz's post... It should be header('Location: http://www.example.com/otherotherpage.php'); missing the colon. Quote Link to comment https://forums.phpfreaks.com/topic/136267-echo/#findComment-711691 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.