LostinSchool Posted April 16, 2009 Share Posted April 16, 2009 I am taking beginner Javascript and PHP at the same time. I understand Javascript but am NOT getting PHP at all. The teacher is horrible- I have basically had to teach myself everything on my own. We have a take home test and I am freaking out because I don't even know where to begin. The assignment is to create a form in HTML or javascript (which is fine- I'm ok with that part) But then I need a submit button which saves the data from the form in a text file, AND I need a link for opening a document that displays the items that were submitting using the form. Can someone give me a sample code? This is due tomorrow so answer ASAP! Thanks!!! Quote Link to comment https://forums.phpfreaks.com/topic/154302-php-beginner-in-school-horrible-teacher-i-am-lost-help/ Share on other sites More sharing options...
LostinSchool Posted April 16, 2009 Author Share Posted April 16, 2009 Just to clarify- I appreciate any kind of help anyone can offer- either a sample code, or even a link to a tutorial that shows how to do that (if anyone out there can just point in the right direction I would really really really appreciate it!) I am just majorly freaking out! ??? Quote Link to comment https://forums.phpfreaks.com/topic/154302-php-beginner-in-school-horrible-teacher-i-am-lost-help/#findComment-811217 Share on other sites More sharing options...
laffin Posted April 16, 2009 Share Posted April 16, 2009 Obviously, ya misinterpreted somethin Create a form submit action shud save the form data to a txt file not submit button, as javascript/html dusn have access to the server. so u sould have the form page the form processing page (after processing, remember show them some confirmation or redirect to another page) and validation page(Shows what u entered, this could be the with form processing) and we dont do homework for ppl. u write code or toss ideas how it shud work and we respond in kind if we gave u the answers, u wudn learn anything Quote Link to comment https://forums.phpfreaks.com/topic/154302-php-beginner-in-school-horrible-teacher-i-am-lost-help/#findComment-811218 Share on other sites More sharing options...
keeB Posted April 16, 2009 Share Posted April 16, 2009 How to deal with files: http://php.net/fopen http://php.net/fwrite http://php.net/fread Plenty of examples there. Quote Link to comment https://forums.phpfreaks.com/topic/154302-php-beginner-in-school-horrible-teacher-i-am-lost-help/#findComment-811220 Share on other sites More sharing options...
LostinSchool Posted April 16, 2009 Author Share Posted April 16, 2009 Thanks so much for trying to help me!!! I really really do appreciate it. I am not looking for you to do my homework for me... but I'm telling you I am in tears right now because I have been reading this book for the past like 7 hours and it is just not sinking in. My teacher hasn't taught me ANYTHING... that's why I'm here. I don't get it, and even your response might as well have been in Chinesebecause I don't really understand it. Is there anyway you can tell me a sample of the code one would use that would submit this form to a text file? Or at least just the function or whatever its called? Oh and on a sidenote, the whole time I've been in class I have never even used Apache because we are blocked from downloading it on our computers at school, so there is no way to even check our work. And I wasn't able to download it at home... so that is part of the reason I am so lost. I honestly just want to get through this class and move on and never do PHP again in my life!!!!!! If there was something Icould help you with in return I would! I'm desperate.... Thanks so so so much. Quote Link to comment https://forums.phpfreaks.com/topic/154302-php-beginner-in-school-horrible-teacher-i-am-lost-help/#findComment-811221 Share on other sites More sharing options...
laffin Posted April 16, 2009 Share Posted April 16, 2009 PHP is a processing lanuage and its quite simple to test the script without a web server. But if U have a usb key, U can build a development environment for php. I have everything but mysql on my usb key, with php, quickphp (a development webserver), and devphp (a php editor) I wud say, first build your form. than work on getting the variables from the form (even if its for display), this will show u yer form is working proper, and that the processing script is getting the variables. once u verify this, u can remove the display portion, and process the form data, in your case save it to a file. than final step is showing the overview of the data, like a spreadsheet (use tables), so a user can select which data to display and finally the display portion. the form u shudn have any problem, but its the start of the whole project the rest is just processing. we point, u read, and think and give ideas and sample code we can fix, refine, suggest. Quote Link to comment https://forums.phpfreaks.com/topic/154302-php-beginner-in-school-horrible-teacher-i-am-lost-help/#findComment-811223 Share on other sites More sharing options...
LostinSchool Posted April 16, 2009 Author Share Posted April 16, 2009 Thanks- I will try to interpret what you said the best I can... I would post sample code but like I said I have no idea what the functions or code things even are. I am a graphic design major so as you can see there is not much use for this stuff. At this point I just want to pass but it looks like that probably isn't happening. Looks like its gonna be an all nighter for me. My javascript take home took me 3 hours to do and I'm sure this will take me even longer.... and I'm also sure its something you guys can do in 5 minutes!! Thanks for tryin I appreciate it. Kate Quote Link to comment https://forums.phpfreaks.com/topic/154302-php-beginner-in-school-horrible-teacher-i-am-lost-help/#findComment-811224 Share on other sites More sharing options...
laffin Posted April 16, 2009 Share Posted April 16, 2009 I can tell u almost exactly wut u will need for php. u can use php.net, to read on how they work, and examples u will need $_POST/$_GET variables $_POST is used with form method "post" which most forms use $_GET is used on the uri, like http://www.google.com?q=tutorials u can use fopen/fwrite/fclose or my preferred functions of file_get_contents/file_put_contents. thats pretty basicly all the functions u need for the php script. but u still need the code to handle the processing (if/else) Quote Link to comment https://forums.phpfreaks.com/topic/154302-php-beginner-in-school-horrible-teacher-i-am-lost-help/#findComment-811227 Share on other sites More sharing options...
LostinSchool Posted April 16, 2009 Author Share Posted April 16, 2009 Awesome thank you... at least I know what to look for. I just finished my javascript code and it works fine... Now I just have to figure out how the submit button will lead to a text file. Quote Link to comment https://forums.phpfreaks.com/topic/154302-php-beginner-in-school-horrible-teacher-i-am-lost-help/#findComment-811266 Share on other sites More sharing options...
laffin Posted April 16, 2009 Share Posted April 16, 2009 Well its not the submit, that just sends something to the server its the other form elements you use for your data. if this was not explained, or wut data to use. U can prolly come up with a few idea Address Book - Name Address City State Zip Reciepes - Name, ingrediants, instructions etc etc etc so either follow the assignment, if it doesnt limit u to what, than come up with something Quote Link to comment https://forums.phpfreaks.com/topic/154302-php-beginner-in-school-horrible-teacher-i-am-lost-help/#findComment-811271 Share on other sites More sharing options...
LostinSchool Posted April 16, 2009 Author Share Posted April 16, 2009 you are really great for helping me! I also looked into some tutorials... I found this code: <?php $Name = addslashes($_POST["name"]); $Department = addslashes($_POST["department"]); $Position = addslashes($_POST["position"]); Will that post it to the text file or just in another browser? Quote Link to comment https://forums.phpfreaks.com/topic/154302-php-beginner-in-school-horrible-teacher-i-am-lost-help/#findComment-811276 Share on other sites More sharing options...
MasterACE14 Posted April 16, 2009 Share Posted April 16, 2009 Will that post it to the text file or just in another browser? neither. That is a security measure. what you don't understand I recommend looking for it in the PHP Manual found at php.net Quote Link to comment https://forums.phpfreaks.com/topic/154302-php-beginner-in-school-horrible-teacher-i-am-lost-help/#findComment-811288 Share on other sites More sharing options...
laffin Posted April 16, 2009 Share Posted April 16, 2009 That cleans up the data after submission. it adds backslashes to the message as to prevent some injections. Like I said work on the form first. than move onto the processing/display scripts. Quote Link to comment https://forums.phpfreaks.com/topic/154302-php-beginner-in-school-horrible-teacher-i-am-lost-help/#findComment-811293 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.