Jump to content

PHP working on local, not when I upload it why?


p595285902

Recommended Posts

Under localhost, the files will be created when I "submit". But it is not working on website when I upload everything.Do I need to download anything into web server or some "magic" stuff I should put on web server from localhost?I am beginner, so I probably missing something.Is it the permission thing that is stopping from user? process.php file

<?php$url=$_POST['url'];$wrong=$_POST['wrong'];$correct=$_POST['correct'];$name=$_POST['name'];$data=$url."\r\n".$wrong."\r\n".$correct."\r\n".$name."\r\n"."\r\n";file_put_contents("data/$name.txt", $data, FILE_APPEND);?>

form file with

<form  method="POST" action="process.php">Website url:		  <textarea rows="1" cols="80" type="text" name="url">url</textarea><br/><!-- if you want a HUGE text area, use <textarea name="myInputName"></textarea> instead -->The wrong sentence:   <textarea rows="2" cols="80" type="text" value="wrong sentence" name="wrong"/> Please type in the wrong sentence</textarea><br/>The correct sentence: <textarea rows="2" cols="80" type="text" value="correct sentence" name="correct"/> Please type in the correct sentence</textarea><br/>Your name:	 <input type="text" value="your name is needed" name="name"/><br/><input type="submit" name"submitButton" value="Submit!" /><br/></form>

Link to comment
Share on other sites

and also you can change it from your cpanel if your host provide it. There is file permission beside the file name in your cpanel file explorer.

Link to comment
Share on other sites

you can also change the permissions in your script using chmod before writing to the file. Basic error handling in this case is a must so you can alert yourself or the user if there were any issues.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...