Jump to content

ifis

Members
  • Posts

    60
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ifis's Achievements

Member

Member (2/5)

0

Reputation

  1. I found a script to validate a form by getElementsByTagName . I have the validation set up to validate <input>s , but I want to add <textarea>s . I'm not too up on javascript and have tried to do some playing around without any sucess. Here is the code: function validate() { var str = ""; var elements = document.getElementsByTagName('input'); // loop through all input elements in form for(var i = 0; i < elements.length; i++) { // check if element is mandatory; ie has a pattern var pattern = elements.item(i).getAttribute('pattern'); if (pattern != null) { var value = elements.item(i).value; // validate the value of this element, using its defined pattern var offendingChar = value.match(pattern); // if an invalid character is found or the element was left emtpy if(offendingChar != null || value.length == 0) { // add up all error messages str += elements.item(i).getAttribute('errorMsg') + "\n" ; // notify user by changing background color, in this case to red elements.item(i).style.background = "yellow"; } } } if (str != "") { // do not submit the form alert("ERROR ALERT!!\n" +str); return false; } else { // form values are valid; submit return true; } } the scipt picks out pattern and errorMsg from the HTML code: <input pattern='[^A-Za-z]' errorMsg='You are missing Answer 1 for question $q' name='aanswer$q' type='text' id='aanswer$q' size='95' /> Thanks for the help!
  2. thanks, that worked. The probably knew I should have escaped it, but was not sure if it would work in an address. Odviously, it does, thanks again.
  3. You can do something like this to send an e-mail to everyone: <?php // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $content=$_POST['content'] $subject=$_POST['subject'] //content and subject of e-mail posted from form $sql = "SELECT * FROM Members"; $result=mysql_query($sql); while($row = mysql_fetch_array($result)) { $address = $row[email]; $name=$row[firstName] ." ". $row[lastName]; //send email $emess= "<html> $content </html>"; $headers= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From:xxxx@php.com'; $mailsnd=mail("$address","$subject","$emess","$headers"); echo "Email send to $name at $address.<br />"; }
  4. I'm trying to pull up an external website within my iframe, but the address has a varaible in it ($FILE) that is messing it up. It works in straight HTML; is there anyway to get this to work easily? <?php $read=$_GET['read']; switch($read) { case 'AC61-25f': echo "<iframe src='http://rgl.faa.gov/Regulatory_and_Guidance_Library/rgAdvisoryCircular.nsf/0/c9461c4231acdc7d86256f1c006f8fce/$FILE/ac60-25f.pdf' frameborder='no' width='100%' height='680'></iframe>"; break; case 'Learning Statement Reference Guide': echo "<iframe src='http://www.faa.gov/education_research/testing/airmen/media/LearningStatementReferenceGuide.pdf' frameborder='no' width='100%' height='680'></iframe>"; break; default: thanks
  5. It WORKED!! I'm still not sure exactly why, I guess it is just using the commas vs. ANDs. Thanks for all the help!
  6. OK, now I got an error: Cannot inset into Endorsementlog table. MySQL Returned: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Endorsement='Private Pilot Practical Test (Single-Engine)',Date='2008/02/27'' at line 1 here is the code I updated: mysql_query("UPDATE Endorsementlog SET end='$dorse',end1='$dorse1',end2='$dorse2' WHERE Student='$student',Endorsement='$lic',Date='$today'")or die("Cannot inset into Endorsementlog table. MySQL Returned: ".mysql_error());
  7. Ok, I echo'd the search and it came out correct, the variables are what they should be. I'll set rid of the AND's and see if that helps.
  8. Ok, I put the code up and it displayed a lot of stuff (new to me, thanks), but it has to do with "undefined index" because I don't set all variables. I'll try the next.
  9. I have a mysql_error() and it does not show anything. Maybe there is a better way to do it. Here is the code I have: mysql_query("UPDATE Endorsementlog SET end='$dorse' AND end1='$dorse1' AND end2='$dorse2' WHERE Student='$student' AND Endorsement='$lic' AND Date='$today'") or die("Cannot inset into Endorsementlog table. MySQL Returned: ".mysql_error()) as far as echo the queary, how would I do that just echo "mysql_query('UPDATE Endorsementlog SET end='$dorse' AND end1='$dorse1' AND end2='$dorse2' WHERE Student='$student' AND Endorsement='$lic' AND Date='$today'') or die('Cannot inset into Endorsementlog table. MySQL Returned: '.mysql_error())"; ?
  10. the he/she has been working, but thanks for the suggestion
  11. I unset the variables because I am connecting to a different database and did not want the original variables that I used to connect to the first database to interfere with the connection with my second database. Basically, I want to get a string that is saved in one database, update the strings variables with inputs from a form and then save the resulted in another database. The script runs without an error message, but does not write anything to the MySQL database. Here is the first part of it //get data $make=$_POST['make']; $lic = $_POST['lic']; $student=$_POST['student']; $sex = $_POST['sex']; $CFI=$_POST['CFI']; $expireip=$_POST['expireip']; $firstName=$_POST['firstName']; $lastName=$_POST['lastName']; $limitations=$_POST['limitations']; $departure=$_POST['departure']; $destination=$_POST['destination']; $route=$_POST['route']; $airport=$_POST['airport']; $airspace=$_POST['airspace']; $landingair=$_POST['landingair']; $seldate=$_POST['seldate']; $pilotcertificate=$_POST['pilotcertificate']; $pilotnumber=$_POST['pilotnumber']; include("endorsement.inc");
  12. I am trying to update a table with a result from another database based off a users selection. I am having a problem updating the table though. The scipt does not produce an error message, but I can't figure out why it does not work. // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); //Convert male/female to he/she if ($sex == 'Male'){ $preposition= he; } If ($sex == 'Female'){ $preposition= she; } $sql = "SELECT * FROM Endorsements WHERE lic='$lic'"; $result=mysql_query($sql); //get the first entry from the result $row = mysql_fetch_array($result); $find = array("\$student","\$make","\$preposition","\$firstName","\$lastName","\$CFI","expire","limitations","departure","destination","\$route","\$airport","landingair","\$airspace","seldate","pilotcertificate","pilotnumber"); $replace = array($student,$make,$preposition,$firstName,$lastName,$CFI,$expireip,$limitations,$departure,$destination,$route,$airport,$landingair,$airspace,$seldate,$pilotcertificate,$pilotnumber); $dorse =str_replace($find,$replace,$row['end']); $dorse1 =str_replace($find,$replace,$row['end1']); $dorse2 =str_replace($find,$replace,$row['end2']); echo "$dorse</br>"; echo "$dorse1</br>"; echo "$dorse2</br>"; unset($host); unset($username); unset($password); unset($db_name); include("endorsementlog.inc"); // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $today=date("Y/m/d"); mysql_query("UPDATE Endorsementlog SET end='$dorse' AND end1='$dorse1' AND end2='$dorse2' WHERE Student='$student' AND Endorsement='$lic' AND Date='$today'") or die("Cannot inset into Endorsementlog table. MySQL Returned: ".mysql_error()); mysql_close(); It's probably something stupid, but I'm stuck. Thanks
  13. yeah, your totally right and it kind of makes sense. It works once I changed it. Thanks for the help!
×
×
  • 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.