Jump to content

jaArch

Members
  • Posts

    47
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jaArch's Achievements

Member

Member (2/5)

0

Reputation

  1. Well I tried to switch it up a bit and am officially stumped...here's my entire code: <? $PROVINCES = array( "--" => "--- Please Select Provinces ---", "nf"=>"Newfoundland", "pe"=>"Prince Edward Island", "nb"=>"New Brunswick", "ns"=>"Nova Scotia", "qc"=>"Quebec", "on"=>"Ontario", "mb"=>"Manitoba", "sk"=>"Saskatchewan", "ab"=>"Alberta", "bc"=>"British Columbia", "nt"=>"Northwest Territories"); if ($_SERVER['REQUEST_METHOD'] == 'POST'): if (empty($_POST['name'])): $errMsg['name'] = "Name cannot be empty."; else: $succMsg['name'] = "NAME = {$_POST['name']}"; endif; if (empty($_POST['city'])): $errMsg['city'] = "City must not be empty."; else: $succMsg['city'] = "CITY = {$_POST['city']}"; endif; if (isset($_POST['status1'])): $succMsg['status1'] = "STATUS = {$_POST['status1']}"; else: $errMsg['status1'] = 'Must select a status.'; endif; foreach($_POST['location'] as $value){ if (isset($_POST['value'])): $succMsg['location'] = "LOCATION = ".$_POST['value']; else: $errMsg['location'] = "Must select a location."; endif; } if (isset($_POST['province'])): $succMsg['province'] = "PROVINCE = {$_POST['province']}"; else: $errMsg['province'] = "Must select a province."; endif; if(ereg('(Mr\.|Mrs\.)',$_POST['name']) == false): $errMsg['fullname'] = "Fullname not entered correctly."; endif; if (count($errMsg) > 0): $dispErrMsgs = true; else: $dispSuccessMsg = true; endif; endif; ?> <html> <head> </head> <body> <p><a href="<?= $_SERVER['PHP_SELF'] ?> ">Refresh This Page</a></p> <? if ($dispErrMsgs): ?> <p>There are errors in the code: </p> <ol> <? foreach($errMsg as $errMsgs ): ?> <li><?= $errMsgs ?></li> <? endforeach; ?> </ol> <? endif; ?> <? if ($dispSuccessMsg): ?> <p>Thank you for your submission. </p> <ol> <? foreach($succMsg as $succMsgs ): ?> <li><?= $succMsgs ?></li> <? endforeach; ?> <? endif; ?> <form action="<?= $_SERVER['PHP_SELF'] ?>" name="getstuff" method="post" > <input type="hidden" name="_act" value="post"> <label>Name</label> <p> <input name="name" type="text" class="textbox" value="<? $_POST['name']; ?>" size="20"> </p> <label>City</label> <p> <input name="city" type="text" class="textbox" value="<? $_POST['city']; ?>" size="20"> </p> <label>Location</label> <p> <input name="location1" id="radio1" value="<?=$_POST['garage'] ?>" type="radio" /> <label for="radio1">Garage</label> <input name="location2" id="radio2" value="<?=$_POST['home'] ?>" type="radio" /> <label for="radio1">Home</label> </p> <label>Provinces</label> <p> <select name = "province[]" multiple size = "12" id="type" > <? foreach ($PROVINCES as $abbreviation => $longname){ ?> <option value = "<?= $abbreviation ?>"> <?= $longname ?></option> <? } ?> </select> </p> <label>Select status</label> <p> <input name="status1" id="approved" value="<?= $_POST['approved'] ?>" type="checkbox" /> <label for="approved">Approved</label> <input name="status2" id="pending" value="<?=$_POST['pending'] ?>" type="checkbox" /> <label for="pending">Pending Application</label> <input name="status[]" id="actives" value="actives" type="checkbox" /> <label for="actives">Active Service</label> </p> <p> <input name="_submit" type="submit" class="button" value="Submit"> </p> </form> <? $a = ('name'); $b = ('city'); $trim = ($a); $trim = ($b); echo "<pre>" . print_r($_POST,1) . "</pre>"; ?> </body> </html>
  2. Yeah, I've tried that: foreach($_POST['location'] as $value){ if (isset($_POST['value'])): $succMsg['location'] = "LOCATION = $value"; else: $errMsg['location'] = "Must select a location."; endif; } It just says LOCATION = when I select something
  3. That one didn't really work. So I tried this: foreach($_POST['location'] as $value){ if (isset($_POST['value'])): $succMsg['location'] = "LOCATION = {$_POST['location']}"; else: $errMsg['location'] = "Must select a location."; endif; } <input name="location[]" id="radio1" value="<?=$_POST['garage'] ?>" type="radio" /> <label for="radio1">Garage</label> <input name="location[]" id="radio2" value="<?=$_POST['home'] ?>" type="radio" /> <label for="radio1">Home</label> But when I test it out it only prints "Array" instead of what I originally selected. Could you help me with this part as well? Thanks
  4. Hi: How do I check to see if a checkbox has not been checked? Would the same rules apply to a radiobutton? This is what I have: <input name="status[1]" id="approved" value="<?php echo $_POST['approved'] ?>" type="checkbox" /> <label for="approved">Approved</label> if (isset($_POST['status[1]'])): $errMsg['status[1]'] = "Must select a status."; endif; I tested it out, but it just prints the error message even if I have checked it
  5. Now I'm getting this error message: Fatal error: Function name must be a string in /home/students/000136921/public_html/10065/php/5/formvalregexpr.php on line 47 What does that mean?
  6. I think I figuerd it out. Thanks Now I can't seem to figure out why it won't display the error message whenever I leave teh first field empty. Here's my code: <? if ($_POST['_act'] = 'csv'): $fp = fopen('logfile.txt', 'r'); while (($data = fgetcsv($fp, 1000, ",")) !== FALSE){ print_r($data); } fclose($fp); endif; if ($_SERVER['REQUEST_METHOD'] == 'POST'): if (empty($_POST['fullname'])): $errMsg['fullname'] = "Please fill in Your Full Name."; endif; if (ereg("'Mr\. '", $_POST['fullname']) == false): $errMsg['fullname'] = "Please fill in Your Full Name."; endif; print_r($errMsgs); echo count($errMsgs); if (count($disperrMsgs) > 0): $dispErrMsgs = true; else: $fp = fopen('logfile.txt', 'r'); $fputcsv($fp, array("test", "lol", "roool")); fclose($fp); $dispSuccessMsg = true; endif; endif; ?> <html> <head> <style type="text/css"> h1 {color:red} div.error {border: 1px solid red; margin: 20px; padding: 20px; width: 400px} table {border: 1px solid #CCC; margin: 20px; border-collapse: collapse;} td, th {border: 1px solid #DDD; padding: 2px} th {background-color:#363; color: white} td.error {color:red} div.success {border: 1px solid green; margin: 20px; padding: 20px; width: 400px; color:green} </style> </head> <body> <h1> Form Validation Lab with Reg Expressions </h1> <p><a href="<?= $_SERVER['PHP_SELF'] ?> ">Refresh This Page</a> | <a href="./logfile.txt">Show Logfile.txt</a> | <a href="<?= $_SERVER['PHP_SELF'] ?>?_act=csv">Show logfile.txt Formatted</a> <a href="<?= $_SERVER['PHP_SELF'] ?>?_act=clear">Clear logfile.txt </a></p> <? if ($dispErrMsgs): ?> <div class="error"> <p>There are errors in the code: </p> <ol> <? foreach($errMsg as $errMsgs ): ?> <li><?= $errMsgs ?></li> <? endforeach; ?> </ol> </div> <? endif; ?> <? if ($dispSuccessMsg): ?> <div class="success"> <p>Thank you for your submission. </p> </div> <? endif; ?> <form action="<?= $_SERVER['PHP_SELF'] ?>" name="getstuff" method="post" > <input type="hidden" name="_act" value="post"> <table cellspacing = "0"> <tr> <th width="78">Full Name:</th> <td width="184"><input name="fullname" type="text" class="textbox" value="<? $_POST['fullname']; ?>" size="20" ></td> <td width="626" >Salution of Mr. or Mrs. followed by two text strings separated by any number of spaces. </td> </tr> <tr> <th>Street:</th> <td><input name="street" type="text" class="textbox" value="<? $_POST['street']; ?>" size="30"></td> <td >2 or 3 digit number followed by a text string ending with Street or Road separated by any number of spaces. </td> <tr> <th>Phone:</th> <td><input name="phone" type="text" class="textbox" value="<? $_POST['phone']; ?>" size="20"></td> <td >10 digits, first 3 digits have optional parentheses, either side of digits 456 are optional space, dot or hyphen. </td> </tr> <tr> <th>PostalCode:</th> <td><input name="postcode" type="text" class="textbox" value="<? $_POST['postcode']; ?>" size="8" maxlength="8"></td> <td > Postal Code: Char Char Digit Hyphen/space Char Digit Digit (No XYZ or 0's. Case insensitive. )</td> </tr> <tr> <th>Email:</th> <td><input name="email" type="text" class="textbox" value="<? $_POST['email']; ?>" size="25" maxlength="40"></td> <td > Must accept as a minimum : a@b.com</td> </tr> </table> <input name="reset" type='button' class="button" value='RESET' onClick="location.href = location.href"> <input name="_submit" type="submit" class="button" value="Submit me now!!!" > </form> <p id="notice">Everything below here is for testing purposes Don't remove this from your lab as I will use these buttons to fill your form with good and bad data as I mark it.</p> <script> az=document.getstuff; function goodstuff(){ az.fullname.value=" Mr. Joe Smith "; az.street.value="135 Fennell Road "; az.phone.value="905-575.1212"; az.postcode.value="Ln9-T23"; az.email.value="jsmith@gov.ca"; } function goodstuff2(){ az.fullname.value=" Mrs. Josephine Smith "; az.street.value=" 13 Fennell Street"; az.phone.value=" (905)-575.1212 "; az.postcode.value=" Ln9 T23"; az.email.value=" jsmith@gov.ca "; } function badstuff(){ az.fullname.value="Miss Josephine Smith"; az.street.value="1 Somewhere Avenue"; az.phone.value="905575122"; az.postcode.value="Z8N 3T2"; az.email.value="jsmith$gov#ca"; } function badstuff2(){ az.fullname.value=" Joe Smith "; az.street.value=" 1392 Fennell Street"; az.phone.value="[905] 575-1212"; az.postcode.value=" Ly9 T20"; az.email.value=" @jsmith$gov#ca"; } function goodandbad(){ az.fullname.value="Mrs. Joe"; az.street.value=" 135 Fennell Avenue West"; az.phone.value="905:5751212"; az.postcode.value=" L99-T23"; az.email.value=" jsmith@.gov.ca "; } </script> <form> <input type=button class="button" onClick="goodstuff();" value="Fill form with good values " length=100 > <input type=button class="button" onClick="goodstuff2();" value="Fill form with good values 2 " > <input type=button class="button" onClick="badstuff();" value="Fill form with BAD values "> <input type=button class="button" onClick="badstuff2();" value="Fill form with BAD values 2 "> <input type=button class="button" onClick="goodandbad();" value="Fill form with Good and BAD values 2"> <br> </form> </BODY> </HTML>
  7. Hmm, another problem I'm having is when I enter in valid data on the form the error message appears when it should only display the success message. Is there a reason for this? I can't seem to figure this part out <? if ($_POST['_act'] = 'csv'): $fp = fopen('logfile.txt', 'r'); while (($data = fgetcsv($fp, 1000, ",")) !== FALSE){ print_r($data); } fclose($fp); endif; if ($_SERVER['REQUEST_METHOD'] == 'POST'): if (empty($_POST['fullname'])): $errMsg['fullname'] = "Please fill in Your Full Name."; endif; if (ereg("'Mr\. '", $_POST['fullname']) == false): $errMsg['fullname'] = "Please fill in Your Full Name."; endif; print_r($errMsgs); echo count($errMsgs); if (count($disperrMsgs > 0)): $dispErrMsgs = true; else: $fp = fopen('logfile.txt', 'r'); $fputcsv($fp, array("test", "lol", "roool")); fclose($fp); $dispSuccessMsg = true; endif; endif; ?> <html> <head> <style type="text/css"> h1 {color:red} div.error {border: 1px solid red; margin: 20px; padding: 20px; width: 400px} table {border: 1px solid #CCC; margin: 20px; border-collapse: collapse;} td, th {border: 1px solid #DDD; padding: 2px} th {background-color:#363; color: white} td.error {color:red} div.success {border: 1px solid green; margin: 20px; padding: 20px; width: 400px; color:green} </style> </head> <body> <h1> Form Validation Lab with Reg Expressions </h1> <p><a href="<?= $_SERVER['PHP_SELF'] ?> ">Refresh This Page</a> | <a href="./logfile.txt">Show Logfile.txt</a> | <a href="<?= $_SERVER['PHP_SELF'] ?>?_act=csv">Show logfile.txt Formatted</a> <a href="<?= $_SERVER['PHP_SELF'] ?>?_act=clear">Clear logfile.txt </a></p> <? if ($dispErrMsgs): ?> <div class="error"> <p>There are errors in the code: </p> <ol> <? foreach($errMsg as $errMsgs ): ?> <li><?= $errMsgs ?></li> <? endforeach; ?> </ol> </div> <? endif; ?> <? if ($dispSuccessMsg): ?> <div class="success"> <p>Thank you for your submission. </p> </div> <? endif; ?> <form action="<?= $_SERVER['PHP_SELF'] ?>" name="getstuff" method="post" > <input type="hidden" name="_act" value="post"> <table cellspacing = "0"> <tr> <th width="78">Full Name:</th> <td width="184"><input name="fullname" type="text" class="textbox" value="<? $_POST['fullname']; ?>" size="20" ></td> <td width="626" >Salution of Mr. or Mrs. followed by two text strings separated by any number of spaces. </td> </tr> <tr> <th>Street:</th> <td><input name="street" type="text" class="textbox" value="<? $_POST['street']; ?>" size="30"></td> <td >2 or 3 digit number followed by a text string ending with Street or Road separated by any number of spaces. </td> <tr> <th>Phone:</th> <td><input name="phone" type="text" class="textbox" value="<? $_POST['phone']; ?>" size="20"></td> <td >10 digits, first 3 digits have optional parentheses, either side of digits 456 are optional space, dot or hyphen. </td> </tr> <tr> <th>PostalCode:</th> <td><input name="postcode" type="text" class="textbox" value="<? $_POST['postcode']; ?>" size="8" maxlength="8"></td> <td > Postal Code: Char Char Digit Hyphen/space Char Digit Digit (No XYZ or 0's. Case insensitive. )</td> </tr> <tr> <th>Email:</th> <td><input name="email" type="text" class="textbox" value="<? $_POST['email']; ?>" size="25" maxlength="40"></td> <td > Must accept as a minimum : a@b.com</td> </tr> </table> <input name="reset" type='button' class="button" value='RESET' onClick="location.href = location.href"> <input name="_submit" type="submit" class="button" value="Submit me now!!!" > </form> <p id="notice">Everything below here is for testing purposes Don't remove this from your lab as I will use these buttons to fill your form with good and bad data as I mark it.</p> <script> az=document.getstuff; function goodstuff(){ az.fullname.value=" Mr. Joe Smith "; az.street.value="135 Fennell Road "; az.phone.value="905-575.1212"; az.postcode.value="Ln9-T23"; az.email.value="jsmith@gov.ca"; } function goodstuff2(){ az.fullname.value=" Mrs. Josephine Smith "; az.street.value=" 13 Fennell Street"; az.phone.value=" (905)-575.1212 "; az.postcode.value=" Ln9 T23"; az.email.value=" jsmith@gov.ca "; } function badstuff(){ az.fullname.value="Miss Josephine Smith"; az.street.value="1 Somewhere Avenue"; az.phone.value="905575122"; az.postcode.value="Z8N 3T2"; az.email.value="jsmith$gov#ca"; } function badstuff2(){ az.fullname.value=" Joe Smith "; az.street.value=" 1392 Fennell Street"; az.phone.value="[905] 575-1212"; az.postcode.value=" Ly9 T20"; az.email.value=" @jsmith$gov#ca"; } function goodandbad(){ az.fullname.value="Mrs. Joe"; az.street.value=" 135 Fennell Avenue West"; az.phone.value="905:5751212"; az.postcode.value=" L99-T23"; az.email.value=" jsmith@.gov.ca "; } </script> <form> <input type=button class="button" onClick="goodstuff();" value="Fill form with good values " length=100 > <input type=button class="button" onClick="goodstuff2();" value="Fill form with good values 2 " > <input type=button class="button" onClick="badstuff();" value="Fill form with BAD values "> <input type=button class="button" onClick="badstuff2();" value="Fill form with BAD values 2 "> <input type=button class="button" onClick="goodandbad();" value="Fill form with Good and BAD values 2"> <br> </form> </BODY> </HTML>
  8. Thanks! That works. But for some reason it only seems to work whenever I put it into teh file without hardcoding it. But when I hard code like this: $fp = fopen('logfile.txt', 'r'); $fputcsv($fp, array("test", "lol", "roool")); fclose($fp); It doesn't seem to work. Am I doing something wrong?
  9. So that's what the 'a' or 'r' is for! Are those the only commands that are used with it or is there more?
  10. CSV File Reading Displaying CSV file: Clicking the Show Logfile.txt link at the top of the page should display the CSV records inside logfile.txt Displaying CSV records formatted : Clicking the Show logfile.txt Formatted should display the CSV records formatted in an HTML table is descending order (more recent records are at the top). Use this function to convert CSV records back to an array : fgetcsv() I have most of this done and the problem I'm having is trying to read what I put into the file. (I hard coded what should go into the file). Could you tell me what I'm doing wrong and what I should do to fix it? <? if ($_POST['_act'] = 'csv'): $fp = fopen('logfile.txt', 'a'); while (($data = fgetcsv($fp, 1000, ",")) !== FALSE){ print_r($data); } fclose($fp); endif; if ($_SERVER['REQUEST_METHOD'] == 'POST'): if (empty($_POST['fullname'])): $errMsg['fullname'] = "Please fill in Your Full Name."; endif; if (ereg("'Mr\. '", $_POST['fullname']) == false): $errMsg['fullname'] = "Please fill in Your Full Name."; endif; print_r($errMsgs); echo count($errMsgs); if (count($disperrMsgs > 0)): $dispErrMsgs = true; else: $fp = fopen('logfile.txt', 'a'); $fputcsv($fp, array("test", "lol", "roool")); fclose($fp); $dispSuccessMsg = true; endif; endif; ?> <html> <head> <style type="text/css"> h1 {color:red} div.error {border: 1px solid red; margin: 20px; padding: 20px; width: 400px} table {border: 1px solid #CCC; margin: 20px; border-collapse: collapse;} td, th {border: 1px solid #DDD; padding: 2px} th {background-color:#363; color: white} td.error {color:red} div.success {border: 1px solid green; margin: 20px; padding: 20px; width: 400px; color:green} </style> </head> <body> <h1> Form Validation Lab with Reg Expressions </h1> <p><a href="<?= $_SERVER['PHP_SELF'] ?> ">Refresh This Page</a> | <a href="./logfile.txt">Show Logfile.txt</a> | <a href="<?= $_SERVER['PHP_SELF'] ?>?_act=csv">Show logfile.txt Formatted</a> <a href="<?= $_SERVER['PHP_SELF'] ?>?_act=clear">Clear logfile.txt </a></p> <? if ($dispErrMsgs): ?> <div class="error"> <p>There are errors in the code: </p> <ol> <? foreach($errMsg as $errMsgs ): ?> <li><?= $errMsgs ?></li> <? endforeach; ?> </ol> </div> <? endif; ?> <? if ($dispSuccessMsg): ?> <div class="success"> <p>Thank you for your submission. </p> </div> <? endif; ?> <form action="<?= $_SERVER['PHP_SELF'] ?>" name="getstuff" method="post" > <input type="hidden" name="_act" value="post"> <table cellspacing = "0"> <tr> <th width="78">Full Name:</th> <td width="184"><input name="fullname" type="text" class="textbox" value="<? $_POST['fullname']; ?>" size="20" ></td> <td width="626" >Salution of Mr. or Mrs. followed by two text strings separated by any number of spaces. </td> </tr> <tr> <th>Street:</th> <td><input name="street" type="text" class="textbox" value="<? $_POST['street']; ?>" size="30"></td> <td >2 or 3 digit number followed by a text string ending with Street or Road separated by any number of spaces. </td> <tr> <th>Phone:</th> <td><input name="phone" type="text" class="textbox" value="<? $_POST['phone']; ?>" size="20"></td> <td >10 digits, first 3 digits have optional parentheses, either side of digits 456 are optional space, dot or hyphen. </td> </tr> <tr> <th>PostalCode:</th> <td><input name="postcode" type="text" class="textbox" value="<? $_POST['postcode']; ?>" size="8" maxlength="8"></td> <td > Postal Code: Char Char Digit Hyphen/space Char Digit Digit (No XYZ or 0's. Case insensitive. )</td> </tr> <tr> <th>Email:</th> <td><input name="email" type="text" class="textbox" value="<? $_POST['email']; ?>" size="25" maxlength="40"></td> <td > Must accept as a minimum : a@b.com</td> </tr> </table> <input name="reset" type='button' class="button" value='RESET' onClick="location.href = location.href"> <input name="_submit" type="submit" class="button" value="Submit me now!!!" > </form> <p id="notice">Everything below here is for testing purposes Don't remove this from your lab as I will use these buttons to fill your form with good and bad data as I mark it.</p> <script> az=document.getstuff; function goodstuff(){ az.fullname.value=" Mr. Joe Smith "; az.street.value="135 Fennell Road "; az.phone.value="905-575.1212"; az.postcode.value="Ln9-T23"; az.email.value="jsmith@gov.ca"; } function goodstuff2(){ az.fullname.value=" Mrs. Josephine Smith "; az.street.value=" 13 Fennell Street"; az.phone.value=" (905)-575.1212 "; az.postcode.value=" Ln9 T23"; az.email.value=" jsmith@gov.ca "; } function badstuff(){ az.fullname.value="Miss Josephine Smith"; az.street.value="1 Somewhere Avenue"; az.phone.value="905575122"; az.postcode.value="Z8N 3T2"; az.email.value="jsmith$gov#ca"; } function badstuff2(){ az.fullname.value=" Joe Smith "; az.street.value=" 1392 Fennell Street"; az.phone.value="[905] 575-1212"; az.postcode.value=" Ly9 T20"; az.email.value=" @jsmith$gov#ca"; } function goodandbad(){ az.fullname.value="Mrs. Joe"; az.street.value=" 135 Fennell Avenue West"; az.phone.value="905:5751212"; az.postcode.value=" L99-T23"; az.email.value=" jsmith@.gov.ca "; } </script> <form> <input type=button class="button" onClick="goodstuff();" value="Fill form with good values " length=100 > <input type=button class="button" onClick="goodstuff2();" value="Fill form with good values 2 " > <input type=button class="button" onClick="badstuff();" value="Fill form with BAD values "> <input type=button class="button" onClick="badstuff2();" value="Fill form with BAD values 2 "> <input type=button class="button" onClick="goodandbad();" value="Fill form with Good and BAD values 2"> <br> </form> </BODY> </HTML>
  11. Hi: I have written code that will allow a user to upload a file and that will allow the user to view/delete the image when clicking on the link. I'm having trouble in the table where the image information is organized - the table just duplicates information about an image into another column,.how can I fix this? Here's my code: <? if ($handle = opendir('images/')) { while (false !== ($file = readdir($handle))) { $TPL['fileList'][] = array( 'fileName' => $file, 'fileSize' => filesize('images/'.$file), 'fileDate' => 'Jan 2, 2029' ); } } switch ($_REQUEST['act']): default: break; if (empty($_FILES['userfile']['name'])): $TPL['errMsg'] = "No file selected"; $TPL['dispErrMsg'] = true; break; endif; copy ($_FILES['userfile']['tmp_name'], 'images/'.$_FILES['userfile']['name']); break; case 'del': echo "delete this file? ($_GET)['userfile']['name']"; endswitch; ?> <html> <head> <title>Comp10065 - Lab 4: File Upload</title> <style type="text/css"> body {background-color:yellow} div#container {margin-right: auto; margin-left: auto; border: 1px solid #EEEEEE; width: 800px; padding: 10px; background-color:white} h1 {text-align: center; color:orange; background-color:white} table {width: 700px; margin-bottom: 15px} table th {text-align: left;padding: 0px 10 0px 10px} table td{padding: 0px 10 0px 10px; border: 1px solid #AAAAAA} tr.odd {background-color: #EEEEEE} tr.even {background-color: #CCCCCC} .message {color:red} div#debug {border: 1px solid #BBBBBB} </style> <script language="JavaScript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.js"></script> <script type="text/javascript"> function popup(img) { var day= new Date(); var windowParms = 'width=400,height=400,scrollbars,resizable'; var htmlPage = '<html><body><img src="' + img + '"><br>' + ' <form><input type="button" ' + ' onclick="javascript:window.close();" value="Close Window"><br>\n' + ' </form></body></html>\n'; var popupWindow = window.open('',day.getTime(),windowParms); popupWindow.document.write(htmlPage); popupWindow.document.close(); } </script> <script> $(function() { $("div#debug").hide(); $("a#debugLink").click(function () {$("div#debug").toggle("slowly"); }); }); </script> </head> <body > <div id="container"> <h1> Picture Uploader!</h1> <p>Click here to <a href="<?= $_SERVER['PHP_SELF'] ?>">refresh</a> this page.</p> <table> <tr> <th>File Name (<a href="upload.php?act=sortby&col=filename">sort</a>)</th> <th>Size KBytes (<a href="upload.php?act=sortby&col=size">sort</a>)</th> <th>Date</th> </tr> </td> <? foreach($TPL['fileList'] as $key => $val): ?> <td><a href="<?= 'images/'.$val['fileName'] ?>"><?=$val['fileName'] ?></a></td> <td><?= $val['fileName'] ?></td> <td><?= $val['fileSize'] ?></td> <td><?= $val['fileDate'] ?></td> <td><a href="#" onClick="popup('images/uieiuirdi.jpg')" >View</a></td> <td align=center><a href=upload.php?act=del&file=uieiuirdi.jpg>Delete</a></td> </tr> <? endforeach ?> </table> <p class="message">Records sorted by size</p> <form action=upload.php method="post" enctype='multipart/form-data'> <input type="hidden" name="MAX_FILE_SIZE" value="2000000"> <input type="hidden" name="act" value="post"> <input type="file" name="userfile" size="60" value=""> <br> <input type="submit" value="UPLOAD FILE" name="submit">Do not upload large files! </form> <? if($TPL['dispErrMsg']): ?> <p><?= $TPL['errMsg'] ?></p> <? endif; ?> <hr> <p>Click <a href="#" id = "debugLink"> here </a> for debug info. Jquery show/hide effect.</p> <div id="debug"> <p>This debug info is here to help you. You are only required to display the $_POST and $_FILES array</p> <pre > <? print_r($TPL) ?></pre> </div> </div> </body> </html>
  12. What do you mean by ereg has been deprecated?
  13. Hi: Is it possible to use the ereg() function in a file upload script so that the ereg() can recognize whether or not the file type is a .jpg, .gif, .png? I already figured out how to do it without using the ereg() function - but I'm just interested to know if it is possible using ereg()..if so, could you provide me with an example? I'm also a bit confused as to how to use ereg() to recognize file types. Here;s what I've done: function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } if ($image) { $filename = stripslashes($_FILES['image']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { echo '<h1>Unknown extension!</h1>'; $errors=1; } Thanks!
  14. Why delimiter? How's that done?
×
×
  • 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.