mupets_revenge Posted March 3, 2006 Share Posted March 3, 2006 right so the plan is to teach myself php and i though it was going well i seamed to be picking it up but have come up against a brick wall with this script.The script is aimed to use a txt file like a database for a clan site. This is the submit section after we have played a match but i cant seam to get it to write to a file. The data then will be retreived again and posted on teh site through some more code which i am yet to write. It has to be txt as our host does not support mysql and such.So all help is appreciated ...So far have for the form page[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]</head> <body> <form name="form" method="post" action="submit.php"> <p>Type of match - Friendly, league, last minute or mess around </p> <p> <input type="text" name="textfield4"> </p> <p>Opponents </p> <p> <input type="text" name="clan"> </p> <p>Score</p> <p> <input type="text" name="score"></p> <p>Man of match</p> <p> <input type="text" name="manofmatch"> </p> <p>Write up</p> <p> <textarea name="writeup"></textarea> </p> <p> </p> <p> <Input type="submit" name="submit" value="Wee" type="button"> </p></form> </body></html> [/quote]then for submit.php have[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<? php$type=$_POST['form']; $Clan = $_REQUEST['clan']; $score = $_POST['score']; $manofmatch = $_POST['manofmatch']; $writeup = $_POST['writeup']; $fp = fopen("results.txt","a"); if(!$fp) { print "error! The file could not be opened"; exit; } $stringtowrite=$Clan."|".$score."|".$manofmatch."|".$writeup."|".$type; fwrite($fp, $stringtowrite); fclose(fp); Print "$clan" // this was an attempt to see if script was running it didnt print anything ?>Done[/quote]so how far wrong am i?any help is appreciated and i am really sorry if i have made a big error as i have tried my best to use google to find me a solution to this but cant find anythin and its doing my head in. Link to comment https://forums.phpfreaks.com/topic/4031-forum-help/ Share on other sites More sharing options...
AV1611 Posted March 4, 2006 Share Posted March 4, 2006 First, your test didn't work because:Print "$clan";because it is spelled $Clan when you made it... Link to comment https://forums.phpfreaks.com/topic/4031-forum-help/#findComment-14071 Share on other sites More sharing options...
mupets_revenge Posted March 4, 2006 Author Share Posted March 4, 2006 ok will change that thanks but can anyone tell me why it doesnt write to the results.txt file?no matter i solved it[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title>send results</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head> <body> <form name="form" method="post" action="insert.php"> <p>Type of match - Friendly, league, last minute or mess around </p> <p> <input type="text" name="textfield4"> </p> <p>Opponents </p> <p> <input type="text" name="clan"> </p> <p>Score</p> <p> <input type="text" name="score"></p> <p>Man of match</p> <p> <input type="text" name="manofmatch"> </p> <p>Write up</p> <p> <textarea name="writeup"></textarea> </p> <p> </p> <p> <input type="submit" name="Submit" value="Submit"></p></form> </body></html> <?}[/quote][!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?php$type=$_POST['type'];$Clan=$_POST['clan'];$score=$_POST['score'];$manofmatch=$_POST['manofmatch'];$writeup=$_POST['writeup'];$fp = fopen("results.txt","r+"); if(!$fp) { print "error! The file could not be opened"; exit;}$stringtowrite=$Clan."|".$score."|".$manofmatch."|".$writeup."|".$type;fwrite($fp, $stringtowrite);fclose($fp);?>Results submited[/quote]was missing a php tag and a $ on the fclose function. Link to comment https://forums.phpfreaks.com/topic/4031-forum-help/#findComment-14123 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.