Jump to content

Archived

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

mupets_revenge

Forum help

Recommended Posts

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>&nbsp; </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.

Share this post


Link to post
Share on other sites
First, your test didn't work because:

Print "$clan";

because it is spelled $Clan when you made it...

Share this post


Link to post
Share on other sites
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>&nbsp; </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.

Share this post


Link to post
Share on other sites

×

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.