just showing blank page

good morning, I am wondering if anyone can help me, this code does not seem to want to work for me. i tried to fix it and finaly got rid of all the errors but now it is just showing a blank page. [php].

Bowling Tournament Sign up


<?php if (isset($_GET['first_name']) && isset($_GET['last_name']) && isset($_GET['age']) && isset($_GET['average'])) { $BowlerFirst = $_GET['first_name']; $BowlerLast = $_GET['last_name']; $BowlerAge = $_GET['age']; $BowlerAverage = $_GET['average']; $NewBowler = $BowlerLast . ", " . "$BowlerFirst" . "," ."$BowlerAge" . "," ."$BowlerAverage" ."\n"; $BowlersFile = "bowlers.txt"; $file_handle = fopen("bowlers.txt", "rb"); while (!feof($file_handle) ) { $line_of_text = fgets($file_handle); $parts = explode(',', $line_of_text); if (($parts[0] == $BowlerFirst) && ($parts[1] == $BowlerLast)) { break; echo " $parts[0], You have already registered for bowling tor"; } else { file_put_contents("bowlers.txt", $NewBowler, FILE_APPEND); echo "

$BowlerFirst $BowlerLast has been registered for the bowling tournament.

"; } fclose($file_handle); echo "

Enter another?

"; } } ?>[/php]

can anyone offer any suggestions ?
thank you

I even tried to put this in instead

[php]if (strcmp($parts[0], $BowlerFirst == 0) && strcmp($parts[1], $BowlerLast == 0))[/php]

Have a link to the page?

no, no web page just an homework assignment that is kicking me in the …

this is what is displayed after i changed the code to [php]if (strcmp($parts[0], $BowlerFirst == 0) && strcmp($parts[1], $BowlerLast == 0))[/php]

Notice: Undefined offset: 1 in /Applications/XAMPP/xamppfiles/htdocs/COP3847/Chapter 5/BowlingTour.php on line 31
, You have already registered for bowling tor

this is the index php i made to go with it.
I was going to put in a form validator into it after I got the rest working
[php].

Bowling Tournament
</head><header class="body">
<section class="body">

Sign up for Bowling Tournament


<form action = "BowlingTour.php" method="get">  
      
<label> First Name</label>
<input name="first_name" placeholder="Type Here">

<label> Last Name</label>
<input name="last_name" placeholder="Type Here">

<label> Age</label>
<input name="age" placeholder="Type Here">

<label>Average</label>
<input name="average"  placeholder="Type Here">
        


<input id="submit" name="submit" type="submit" value="Submit">
<footer class="body">
</footer>
[/php]

before I put in the while loop it was working, I just wanted to add a validator to it to check if the person had already signed up.

what if i replace the “while” with “do”
and then place the
while
[php] if (strcmp($parts[0], $BowlerFirst !== 0) && strcmp($parts[1], $BowlerLast !== 0))[/php]

blah, i changed it a little, but now it seems to completely ignore the “while loop”
[php].

Bowling Tournament Sign up


<?php if (isset($_GET['first_name']) && isset($_GET['last_name']) && isset($_GET['age']) && isset($_GET['average'])) { $BowlerFirst = $_GET['first_name']; $BowlerLast = $_GET['last_name']; $BowlerAge = $_GET['age']; $BowlerAverage = $_GET['average']; $NewBowler = $BowlerLast . ", " . "$BowlerFirst" . "," ."$BowlerAge" . "," ."$BowlerAverage" ."\n"; $file_handle = fopen("bowlers.txt", "rb"); while (!feof($file_handle) ) { $line_of_text = fgets($file_handle); $parts = explode(',', $line_of_text); if (($parts[0] == $BowlerLast ) && ($parts[1] == $BowlerFirst)) { echo " $parts[0], You have already registered for the Bowling Tournament"; break; fclose($file_handle); } } $BowlersFile = "bowlers.txt"; file_put_contents("bowlers.txt", $NewBowler, FILE_APPEND); echo "

$BowlerFirst $BowlerLast you have been registered for the bowling tournament.

"; } echo "

Enter another?

"; ?> [/php]

i put var_dump($parts); before and after
[php]if (($parts[0] == $BowlerLast ) && ($parts[1] == $BowlerFirst))
{

   echo " $parts[0], You have already registered for the Bowling Tournament"; 
break;[/php]

when I placed the var_dump($parts); it displayed the array but when i placed it after the if statement i would not display.

ok, got it to work

[php].

Bowling Tournament Sign up


<?php if (isset($_GET['first_name']) && isset($_GET['last_name']) && isset($_GET['age']) && isset($_GET['average'])) { $BowlerFirst = $_GET['first_name']; $BowlerLast = $_GET['last_name']; $BowlerAge = $_GET['age']; $BowlerAverage = $_GET['average']; $NewBowler = $BowlerLast . ", " . "$BowlerFirst" . "," ."$BowlerAge" . "," ."$BowlerAverage" ."\n"; $file_handle = fopen("bowlers.txt", "rb"); } $partsmatch = false; while (!feof($file_handle) ) { $line_of_text = fgets($file_handle); $parts = explode(',', $line_of_text); if ($parts[0] == $BowlerLast) { $partsmatch = true; echo "

$BowlerFirst , You have already registered for the Bowling Tournament

"; echo "

Enter another?

"; } } fclose($file_handle); if ($partsmatch != true) { file_put_contents("bowlers.txt", $NewBowler, FILE_APPEND); echo "

$BowlerFirst $BowlerLast you have been registered for the bowling tournament.

"; echo "

Enter another?

"; } ?> [/php]

[member=72989]Elminster[/member]

Good for you! You saved me the time of going through all of it!

[member=69011]Topcoder[/member]

in the index php, is there a way to use the submit button for two or more things? i was thinking of putting a cheap spam protection onto it, add a couple lines in the form section to check if it is a person entering the details or not,

putting something like

what is 2x2
if they answer 4 then continue to next page, if not,

wrong answer, try again

or something like that?

[member=72989]Elminster[/member]

That Cheap spam protection actually works better then most advanced spam protection.

Sponsor our Newsletter | Privacy Policy | Terms of Service