prcollin Posted May 30, 2008 Share Posted May 30, 2008 If i am posting a file to a directory and not into a table in a database how do i connect to the server so that I can post it?? THis is what I have so far let me know if anything is wrong mind you this is just to test this out. This is the html form <html> <head> <title>Post File Practice </title> </head> <body> <form action="createfile.php" method="post"> Enter Your Email Address:<input type="text" name="user_email"> <br><br> Enter A Page Title: <input type="text" name="page_title"> <br><br> Enter Some Info About Yourself: <input type="textarea" name="about_you"> <br><br> <input type="submit" value="Post your Page"> </form> </body> </html> This is createfile.php <?php include ("connect.php"); /** * *This script posts the new file to the directory * * (c) copyright 2008 Time Vision Development */ $page_title = 'page_title'; $user_email = 'user_email'; $about_you = 'about_you'; $fp = fopen('userpages/' . $page_title . '.html', 'a'); fwrite($fp, '<br>'); fwrite($fp, '<br>'); fwrite($fp, '<b>Page Title:</b>'); fwrite($fp, '<br>'); fwrite($fp, $_POST['$page_title']); fwrite($fp, '<br>'); fwrite($fp, '<br>'); fwrite($fp, '<b>Email Address:</b>'); fwrite($fp, '<br>'); fwrite($fp, $_POST['$user_email']); fwrite($fp, '<br>'); fwrite($fp, '<br>'); fwrite($fp, '<b>About Me:</b>'); fwrite($fp, '<br>'); fwrite($fp, $_POST['$about_you']); fwrite($fp, '<br>'); fwrite($fp, '<br>'); fwrite($fp, '<hr height="5" width="100%">'); ?> What else do i need to post directly to a directory?? Link to comment https://forums.phpfreaks.com/topic/107921-still-need-help-badly/ Share on other sites More sharing options...
trq Posted May 30, 2008 Share Posted May 30, 2008 If i am posting a file to a directory and not into a table in a database how do i connect to the server so that I can post it?? What exactly do you meen by posting a file? The code you have shown write a file on the server that the code is running on. Link to comment https://forums.phpfreaks.com/topic/107921-still-need-help-badly/#findComment-553208 Share on other sites More sharing options...
prcollin Posted May 30, 2008 Author Share Posted May 30, 2008 If i am posting a file to a directory and not into a table in a database how do i connect to the server so that I can post it?? What exactly do you meen by posting a file? The code you have shown write a file on the server that the code is running on. then i guess i answered my question already lol Link to comment https://forums.phpfreaks.com/topic/107921-still-need-help-badly/#findComment-553209 Share on other sites More sharing options...
prcollin Posted May 30, 2008 Author Share Posted May 30, 2008 with the code that i used i get all these errrors Warning: fopen(userpages/page_title.html) [function.fopen]: failed to open stream: No such file or directory in /home/findzer/public_html/userpages/createfile.php on line 13 Warning: fwrite(): supplied argument is not a valid stream resource in /home/findzer/public_html/userpages/createfile.php on line 15 Warning: fwrite(): supplied argument is not a valid stream resource in /home/findzer/public_html/userpages/createfile.php on line 16 Warning: fwrite(): supplied argument is not a valid stream resource in /home/findzer/public_html/userpages/createfile.php on line 17 Warning: fwrite(): supplied argument is not a valid stream resource in /home/findzer/public_html/userpages/createfile.php on line 18 Warning: fwrite(): supplied argument is not a valid stream resource in /home/findzer/public_html/userpages/createfile.php on line 20 Warning: fwrite(): supplied argument is not a valid stream resource in /home/findzer/public_html/userpages/createfile.php on line 21 Warning: fwrite(): supplied argument is not a valid stream resource in /home/findzer/public_html/userpages/createfile.php on line 22 Warning: fwrite(): supplied argument is not a valid stream resource in /home/findzer/public_html/userpages/createfile.php on line 23 Warning: fwrite(): supplied argument is not a valid stream resource in /home/findzer/public_html/userpages/createfile.php on line 25 Warning: fwrite(): supplied argument is not a valid stream resource in /home/findzer/public_html/userpages/createfile.php on line 26 Warning: fwrite(): supplied argument is not a valid stream resource in /home/findzer/public_html/userpages/createfile.php on line 27 Warning: fwrite(): supplied argument is not a valid stream resource in /home/findzer/public_html/userpages/createfile.php on line 28 Warning: fwrite(): supplied argument is not a valid stream resource in /home/findzer/public_html/userpages/createfile.php on line 30 Warning: fwrite(): supplied argument is not a valid stream resource in /home/findzer/public_html/userpages/createfile.php on line 31 Warning: fwrite(): supplied argument is not a valid stream resource in /home/findzer/public_html/userpages/createfile.php on line 32 Link to comment https://forums.phpfreaks.com/topic/107921-still-need-help-badly/#findComment-553211 Share on other sites More sharing options...
Steve Angelis Posted May 30, 2008 Share Posted May 30, 2008 Have you properly CHMODed the file? Link to comment https://forums.phpfreaks.com/topic/107921-still-need-help-badly/#findComment-553213 Share on other sites More sharing options...
trq Posted May 30, 2008 Share Posted May 30, 2008 Likely a permissions issue. Make sure php has permission to write to the userpages directory. Link to comment https://forums.phpfreaks.com/topic/107921-still-need-help-badly/#findComment-553215 Share on other sites More sharing options...
trq Posted May 30, 2008 Share Posted May 30, 2008 On a side note, variables are not interpolated when in single quotes. These lines... fwrite($fp, $_POST['$page_title']); will wont to be.... fwrite($fp, $_POST[$page_title]); Link to comment https://forums.phpfreaks.com/topic/107921-still-need-help-badly/#findComment-553217 Share on other sites More sharing options...
prcollin Posted May 30, 2008 Author Share Posted May 30, 2008 Likely a permissions issue. Make sure php has permission to write to the userpages directory. permissions are set for write read all that good stuff. I have full open write privs and all that. Is my syntax right for creating a new file using a variable in the fopen() function?? Link to comment https://forums.phpfreaks.com/topic/107921-still-need-help-badly/#findComment-553220 Share on other sites More sharing options...
prcollin Posted May 30, 2008 Author Share Posted May 30, 2008 bump Link to comment https://forums.phpfreaks.com/topic/107921-still-need-help-badly/#findComment-553235 Share on other sites More sharing options...
haku Posted May 30, 2008 Share Posted May 30, 2008 What do you mean bump - you got a couple different answers. Did you try them? Link to comment https://forums.phpfreaks.com/topic/107921-still-need-help-badly/#findComment-553246 Share on other sites More sharing options...
prcollin Posted May 30, 2008 Author Share Posted May 30, 2008 What do you mean bump - you got a couple different answers. Did you try them? I tried all of the above and after I tried it I replaced my new error message over the old one so the message that is up now isthe one i get now. Link to comment https://forums.phpfreaks.com/topic/107921-still-need-help-badly/#findComment-553448 Share on other sites More sharing options...
haku Posted May 30, 2008 Share Posted May 30, 2008 Post up your code as it is now. Link to comment https://forums.phpfreaks.com/topic/107921-still-need-help-badly/#findComment-553497 Share on other sites More sharing options...
prcollin Posted May 30, 2008 Author Share Posted May 30, 2008 Post up your code as it is now. this is hte html form that feeds the info to createfile.php <html><head> <title>Post File Practice </title></head><body><form action="createfile.php" method="post">Enter Your Email Address:<input type="text" name="user_email"><br><br>Enter A Page Title: <input type="text" name="page_title"><br><br>Enter Some Info About Yourself: <input type="textarea" name="about_you"><br><br><input type="submit" value="Post your Page"></form></body></html> <?php/** * *This script posts the new file to the directory * * (c) copyright 2008 Time Vision Development */ $page_title = 'page_title'; $user_email = 'user_email'; $about_you = 'about_you'; /*this line is to create a file with the page title that they specify in the form that gathers the info*/ $fp = fopen('userpages/' . $page_title . '.html', 'a'); fwrite($fp, '<b>Email Address:</b>'); fwrite($fp, '<br>'); fwrite($fp, $_POST[$user_email]); fwrite($fp, '<br>'); fwrite($fp, '<br>'); fwrite($fp, '<b>About Me:</b>'); fwrite($fp, '<br>'); fwrite($fp, $_POST[$about_you]); fwrite($fp, '<br>'); fwrite($fp, '<br>'); fwrite($fp, '<hr height="5" width="100%">');?> Link to comment https://forums.phpfreaks.com/topic/107921-still-need-help-badly/#findComment-553538 Share on other sites More sharing options...
prcollin Posted May 30, 2008 Author Share Posted May 30, 2008 New code posted anyone have suggestions Link to comment https://forums.phpfreaks.com/topic/107921-still-need-help-badly/#findComment-553594 Share on other sites More sharing options...
BlueSkyIS Posted May 30, 2008 Share Posted May 30, 2008 does the directory userpages exist in the same directory as this script, and is it writable? Link to comment https://forums.phpfreaks.com/topic/107921-still-need-help-badly/#findComment-553605 Share on other sites More sharing options...
prcollin Posted May 30, 2008 Author Share Posted May 30, 2008 does the directory userpages exist in the same directory as this script, and is it writable? yeah it exists and i opened up all permissions Link to comment https://forums.phpfreaks.com/topic/107921-still-need-help-badly/#findComment-553696 Share on other sites More sharing options...
prcollin Posted May 30, 2008 Author Share Posted May 30, 2008 bump Link to comment https://forums.phpfreaks.com/topic/107921-still-need-help-badly/#findComment-553744 Share on other sites More sharing options...
haku Posted June 1, 2008 Share Posted June 1, 2008 The script syntax seems to be ok, which leads me to think its a permissions problem on the directory in question, assuming you are still getting the same error as you have posted already in this thread. Try giving the directory all permissions that you can (I believe you want 777), and then run the script again, if it works, that was your problem. If not, post the error up here again please. Link to comment https://forums.phpfreaks.com/topic/107921-still-need-help-badly/#findComment-554660 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.