Jump to content

Forum help


mupets_revenge

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.
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.