Jump to content

Kiwii

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Everything posted by Kiwii

  1. Try this <?php $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; if (!isset($_REQUEST['email'])) {header( "Location: ../website/feedback.html" ); } elseif($fullname == '' or $email == '' or $Schoolyear == '' or $RA1 == '' or $RA2 == ''){header( "Location: ../website/feedbacke.html" ); } else { $to = 'gjunk@kolsassoon.org.uk'; $subject = 'gjunk@kolsassoon.org.uk'; $from = $fullname; $message = 'Email: '.$email.'\n School: '.$school.'\n School Year: '.$Schoolyear.'\n How did you find out about MFE: '.$RA1.'\n What did you like about the site: '.$CB.'\n Difficulty of site: '.$RA2.'\n Improvements: '.$Sitebetter.'\n One Word: '.$Feeling; mail($to, $subject, $message, $from) header( "Location: ../website/feedbacks.html" ); ) ?>
  2. you can just do another query? require_once "connect_to_mysql.php"; $query = "SELECT * FROM table WHERE id=".$_GET['id']; $result=mysql_query($query); $query2 = "SELECT * FROM table2"; $result2=mysql_query($query2); while($row = mysql_fetch_array($result)){ $b1 = $row["fieldzero"]; $b2 = $row["fieldone"]; $b3 = $row["fieldtwo"]; $b5 = $row["fieldthree"]; $b6 = $row["fieldfour"]; $b7 = $row["fieldfive"]; $b8 = $row["fieldsix"]; } while($row2 = mysql_fetch_array($result2)){ $b1 = $row2["fieldzero"]; $b2 = $row2["fieldone"]; $b3 = $row2["fieldtwo"]; $b5 = $row2["fieldthree"]; $b6 = $row2["fieldfour"]; $b7 = $row2["fieldfive"]; $b8 = $row2["fieldsix"]; } not totally sure it will work but can't see why not?
  3. If you just want to display the data from your database into your div tags then $result = mysql_query(" SELECT * FROM example ") or die(mysql_error()); $row = mysql_fetch_array($result); echo "<div id='name'>".$row['text']."</div>";
  4. Why would you want to? Surely you'll be typing that data into the div so why not just type it into the database?
  5. yeah i'm sure i'm only pressing it ones, i've done it many times. i'm sure if i add a script to make it check if the name and age already exists it will only input it onces but i can't think of that script. i tried a few times but just got errors, what you think?
  6. CREATE TABLE IF NOT EXISTS `example` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(30) DEFAULT NULL, `age` int(11) DEFAULT NULL, KEY `id` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; CREATE TABLE IF NOT EXISTS `example2` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(30) DEFAULT NULL, `fav_food` varchar(50) DEFAULT NULL, KEY `id` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
  7. the table you created is called 'log_March2010' not 'tbl_log'
  8. So. i've made a really simple form (learning the basics of mysql + php) to send someones name and age into one table and name and favourite food into another. It works but the only trouble is that it sends it four times. Like i'll press submit and then the information will appear in the database multiple times. Anyway, this is the html form code: <form action="sent.php" method="get"> Forename: <input type="text" name="fname" /><br/> Age: <input type="text" name="age" /><br/> Favourite Food: <input type="text" name="fav_food" /><br/> <input type="submit" value="Submit to database"/> </form> and this is the php: <?php mysql_connect("localhost", "admin", "1admin") or die(mysql_error()); mysql_select_db("test") or die(mysql_error()); $name = $_GET['fname']; $age = $_GET['age']; $fav_food = $_GET['fav_food']; mysql_query("INSERT INTO example (name, age) VALUES('$name', '$age') ") or die(mysql_error()); mysql_query("INSERT INTO example2 (name, fav_food) VALUES('$name', '$fav_food') ") or die(mysql_error()); echo 'Added '.$name.' who is '.$age.' and loves ' .$fav_food. ' to the database.'; ?> Oh and i have mysql 5.1.36 and php 5.3.0 Thankyou
×
×
  • 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.