CAiNSTUHhh Posted August 7, 2009 Share Posted August 7, 2009 <?php if(isset($_POST['submit')) { $fp = fopen ("file.txt", "a+"); $name = $_POST['name']; $myspaceid = $_POST['myspaceid']; $info = $name . "|" . $myspaceid; fwrite($fp, $info) fclose($fp); } else { //show the form ?> <form name="myspace_train_submitter" action="train.php" method="post"> Name: <input type="text" name="name" id="name" /><br /> Myspace ID#: <input type="text" name="myspaceid" id="myspaceid" /> <input type="submit" name="submit" value="Add »" /> </form> <?php } ?> on here [http://cain.justfree.com/jumpon.php] wont show whenever i posted it it just went off. Link to comment https://forums.phpfreaks.com/topic/169283-php-wont-show/ Share on other sites More sharing options...
p2grace Posted August 7, 2009 Share Posted August 7, 2009 Try this: <?php if(isset($_POST['name')) { $fp = fopen ("file.txt", "a+"); $name = $_POST['name']; $myspaceid = $_POST['myspaceid']; $info = $name . "|" . $myspaceid; fwrite($fp, $info) fclose($fp); } else { //show the form ?> <form name="myspace_train_submitter" action="train.php" method="post"> Name: <input type="text" name="name" id="name" /><br /> Myspace ID#: <input type="text" name="myspaceid" id="myspaceid" /> <input type="submit" name="submit" value="Add »" /> </form> <?php } ?> You didn't have a field called "submit" so the php never grabbed the data from $_POST. Link to comment https://forums.phpfreaks.com/topic/169283-php-wont-show/#findComment-893292 Share on other sites More sharing options...
CAiNSTUHhh Posted August 7, 2009 Author Share Posted August 7, 2009 Still, Nothing showed up. just a blank page :/ I really need this eh Haha. Link to comment https://forums.phpfreaks.com/topic/169283-php-wont-show/#findComment-893294 Share on other sites More sharing options...
p2grace Posted August 7, 2009 Share Posted August 7, 2009 Time to display errors, add this to the top of your script: /* Enable displaying of errors */ error_reporting(E_ALL); ini_set('display_errors', 'On'); Then post the errors found, along with the actual lines of code corresponding to the error lines. Link to comment https://forums.phpfreaks.com/topic/169283-php-wont-show/#findComment-893297 Share on other sites More sharing options...
CAiNSTUHhh Posted August 7, 2009 Author Share Posted August 7, 2009 Could it be the website? Link to comment https://forums.phpfreaks.com/topic/169283-php-wont-show/#findComment-893298 Share on other sites More sharing options...
p2grace Posted August 7, 2009 Share Posted August 7, 2009 Display your errors and we can go from there. If no errors display and you still get a white screen, then we know it's a syntax issue. Link to comment https://forums.phpfreaks.com/topic/169283-php-wont-show/#findComment-893300 Share on other sites More sharing options...
CAiNSTUHhh Posted August 7, 2009 Author Share Posted August 7, 2009 No Errors display. Its just a White screen. Link to comment https://forums.phpfreaks.com/topic/169283-php-wont-show/#findComment-893301 Share on other sites More sharing options...
Mardoxx Posted August 7, 2009 Share Posted August 7, 2009 if(isset($_POST['name')) { STRAIGHTEN OUT THAT BRACKET ARRAYS ARE STRICTLY NON GAY! if(isset($_POST['name']) { Link to comment https://forums.phpfreaks.com/topic/169283-php-wont-show/#findComment-893306 Share on other sites More sharing options...
p2grace Posted August 7, 2009 Share Posted August 7, 2009 Yeah just noticed the syntax issue. <?php if(isset($_POST['name'])) { $fp = fopen ("file.txt", "a+"); $name = $_POST['name']; $myspaceid = $_POST['myspaceid']; $info = $name . "|" . $myspaceid; fwrite($fp, $info) fclose($fp); } else { //show the form ?> <form name="myspace_train_submitter" action="train.php" method="post"> Name: <input type="text" name="name" id="name" /><br /> Myspace ID#: <input type="text" name="myspaceid" id="myspaceid" /> <input type="submit" name="submit" value="Add »" /> </form> <?php } ?> This should do the trick. Link to comment https://forums.phpfreaks.com/topic/169283-php-wont-show/#findComment-893307 Share on other sites More sharing options...
Mardoxx Posted August 7, 2009 Share Posted August 7, 2009 fwrite($fp, $info) semicolon please fwrite($fp, $info); ----- working code: <?php if(isset($_POST['name'])) { $fp = fopen ("file.txt", "a+"); $name = $_POST['name']; $myspaceid = $_POST['myspaceid']; $info = $name . "|" . $myspaceid; fwrite($fp, $info); fclose($fp); } else { //show the form ?> <form name="myspace_train_submitter" action="train.php" method="post"> Name: <input type="text" name="name" id="name" /><br /> Myspace ID#: <input type="text" name="myspaceid" id="myspaceid" /> <input type="submit" name="submit" value="Add »" /> </form> <?php } ?> also, if you're going to be harvesting passwords with this, make it fwrite AND login so they're none-the-wiser Link to comment https://forums.phpfreaks.com/topic/169283-php-wont-show/#findComment-893308 Share on other sites More sharing options...
CAiNSTUHhh Posted August 7, 2009 Author Share Posted August 7, 2009 it wont post to the text file whenever i click ADD WHat i am trying to do is to make it so whenever it clicks add it adds to this train [ cain.justfree.com/T/train.php And that is a Text file that saves the information and posts to the train Link to comment https://forums.phpfreaks.com/topic/169283-php-wont-show/#findComment-893313 Share on other sites More sharing options...
jamesxg1 Posted August 8, 2009 Share Posted August 8, 2009 A code i made, May help ?. <?php if(isset($_POST['submit'])) { $country = $_POST['element_3_6']; $name = $_POST['element_1']; $telephone = $_POST['element_2']; $address = $_POST['element_3_2']; $addresstwo = $_POST['element_3_1']; $city = $_POST['element_3_3']; $state = $_POST['element_3_4']; $postcode = $_POST['element_3_5']; $contents .= '("' .$name . '","' . $telephone . '","' . $address . '","' . $addresstwo . '","' . $postcode . '","' . $city . '","' . $state . '","' . $postcode . '","' . $country . '"),' . "\n" ; $filename = 'datafiles.rtf'; if (is_writable($filename)) { if (!$handle = fopen($filename, 'a')) { echo "Cannot open file ($filename)"; exit; } if (fwrite($handle, $contents) === FALSE) { echo "Cannot write to file ($filename)"; exit; } echo "<font color='white'>Success, Restraunt added.</font>"; fclose($handle); } else { echo "The file $filename is not writable"; } } ?> James. Link to comment https://forums.phpfreaks.com/topic/169283-php-wont-show/#findComment-893379 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.