Jump to content

dhmyers82

Members
  • Content Count

    22
  • Joined

  • Last visited

Community Reputation

0 Neutral

About dhmyers82

  • Rank
    Member
  1. When it is a .php file with a form and the action calls itself. The validations are running before the user even has a chance to enter in any data. I just reread the question and I think they should be separate files with all the data being appended to a "single" .txt file
  2. Sorry, where would you like me to post questions like this?
  3. Please tell me if I am thinking correctly I have a .html doc with a form. The form has an action calling a php file. The action is called when I hit submit. How does it work with an all-in-one form? Why is the php running as the page loads and not when I hit submit?
  4. When checking validity do I want to stripslashes before or after I check?
  5. I have no idea what it was doing. I came back to it and re-uploaded it and it is working fine. Thank you all for looking it over.
  6. I keep getting this error "Parse error: syntax error, unexpected '=' in /home/143/dmyers/public_html/sdev253/php/FileDownloader.php on line 4" How is the '=' not needed. Its straight from the stupid book... I hate php today <?php $dir = "files"; if (isset($_GET['filename'])) { $fileToGet = $dir. "/" .stripcslashes($_GET['filename']); if (is_readable($fileToGet)) { header("Content-Description: File Transfer"); header("Content-Type: application/force-download"); header("Content-Disposition: attachment; filename=\"" .$_GET['filename']. "\""); header("Content-Transfer-Encoding: base64"); header("Content-Length: " .filesize($fileToGet)); readfile($fileToGet); $showErrorPage = FALSE; } else { $errorMsg = "Cannot read \"$fileToGet\""; $showErrorPage = TRUE; } } else { $errorMsg = "No filename specified"; $showErrorPage = TRUE; } if ($showErrorPage) { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "html://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>File Downloader</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> </head> <body> <p>There was an error downloading "<?php echo htmlentities($_GET['filename']); ?></p> <p><?php echo htmlentities($errorMsg); ?></p> </body> </html> <?php } ?>
  7. Thanks it was not saved as a .php and I know the HTML format has no bearing on it working. I have just had people tell me I need to be using HTML5 instead of XHTML, I was just trying to avoid more comments of that nature.
  8. There has to be an error in the php that I am not seeing as I am getting php script echoed in the top of the document. Also It is not finding the server. I dont know if this is becaus of the error I can't find or something else. Yes I know it is in XHTML. I am using an outdated book. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "html://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>[TEMPLATE]</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> </head> <body> <?php error_reporting(E_ALL); ini_set('display_errors', 'on'); $dir = "files"; if (isset($_POST['upload'])) { if (isset($_FILES['new_file'])) { if (move_uploaded_file($_FILES['new_file']['tmp_name'], $dir. "/" .$_FILES['new_file']['name']) == True) { chmod($dir. "/" .$_FILES['new_file']['name'], 0644); echo "File \"" .htmlentities($_FILES['new_file']['name']). "\"successfully uploaded.<br />\n"; } else echo "There was an error uploading \"" .htmlentities($_FILES['new_file']['name']). "\".<br />\n"; } } ?> <form action="FileUploader.php" method="POST" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="25000" /><br /> File to upload:<br /> <input type="file" name="new_file" /><br /> (25000 byte limit) <br /> <input type="submit" name="upload" value="Upload the File" /> <br /> </form> </body> </html> Thank you for the help.
  9. That will do it. Thanks.
  10. <h2>Scholarship Form</h2> <form name="scholarship" action="process_Scholarship.php" method="post"> <p>First Name: <input type="text" name="fname" /></p> <p>Last Name: <input type="text" name="lname" /></p> <p><input type="reset" value="Clear Form" /> <input type="submit" value="Send Form" /></p> </form> <?php error_reporting(E_ALL); ini_set('display_errors', 'on'); $firstName = validateInput($_POST['fname'], "First Name"); $lastName = validateInput($_POST['lname'], "Last Name"); if ($errorCount<0) echo "Please use the \"Back\" button to re-enter data.<br />\n"; else echo "<p>Thank you for filling out the scholarship form, ".$firstName." ".$lastName."."; function displayRequired($fieldName) { echo "The field \"$fieldName\" is required.<br />\n"; } function validateInput($data, $fieldName) { global $errorCount; if (empty($date)) { displayRequired($fieldName); ++$errorCount; $retval = ""; } else {//Only clean up the input if it isn't empty $retval = trim($data); $retval = stripslashes($retval); } return($retval); } $errorCount = 0; ?> it always reads the form as empty, and spits out the error message. why will it not read the names I enter?
  11. Thank you, PHP is making me want to throw my computer out the window... Its for homework so it has to be a "for". When Im done with this I get to change it to a "while". Im so excited
  12. I keep getting the following error: Fatal error: Function name must be a string in /home/dmyers53/public_html/Projects/Chisese_Zodiac_for_loop.php on line 34 I dont have a function named, where am I going wrong? <body> <img src="images/rat.jpg"></img><!--test the source. WORKS--> <?php error_reporting(E_ALL); ini_set('display_errors', 'on'); echo "<p>This line works</p>\n";//yes it does $zodiacPictures = array( "images/rat.jpg", "images/ox.jpg", "images/tiger.jpg", "images/rabbit.jpg", "images/dragon.jpg", "images/snake.jpg", "images/horse.jpg", "images/sheep.jpg", "images/monkey.jpg", "images/rooster.jpg", "images/dog.jpg", "images/pig.jpg"); for ($imgCounter = 0; $imgCounter <= 12; ++$imgCounter){ echo '<img src="' . $zodiacPictures($imgCounter) . '"></img>';// line 34 } ?> </body> </html>
  13. Thank you. I find it stupid that the book has us using xhtml, and <div>! i was taught html 5 as you can see by my tags. I just haven't converted the head over yet.
  14. Nevermind, Thank you. Sorry I combined two lines from my book and saw it as soon as I went back to look again. $extraFields = 0; $currField = strtok($record, ":");
  15. Having issues with an in book problem. I keep getting and "Undefined variable" Notice on the line that starts with "while ($currField != NULL) {" I am assuming it has something to do with the not NULL but I have no clue on this one folks. <?php error_reporting(E_ALL); ini_set('display_errors', 'on'); $record = "jdoe:8W4dS03a39Yk2:1463:24:John Doe:/home/jdoe:/bin/bash"; $passwordFields = array( "login name", "optional encrypted password", "numerical user ID", "numerical group ID", "user name or comment field", "user home directory", "optional user command interpreter"); $fieldIndex = 0; $extraFields = strtok($record, ":"); while ($currField != NULL) { if ($fieldIndex < count($passwordFields)) echo "<p>The {$passwordFields[$fieldIndex]} is <em>$currField</em></p>\n"; else { ++$extraFields; echo "<p>Extra Field # $extraFields is <em>$currField</em></p>\n"; } $currField = strtok(":"); ++$fieldIndex; } ?>
×
×
  • 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.