Jump to content

STILL NEED HELP BADLY


prcollin

Recommended Posts

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

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

 

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

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??

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%">');?>

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.