Jump to content

mike2fast

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Everything posted by mike2fast

  1. Hi, When i put it in PHP tags it just wont edit any of the data. Any ideas?
  2. Hi guys, just wondering if someone can help me i am currently trying to edit a MYSQL database through PHP and just wondering if you could take a look at the code i have and tell me where i have gone wrong. I have tried to use a tutorial but have got lost and need some help. This is for my final year project for University and really needs to be done soon so i would be really greatful if someone could help me out. Thanks code below: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <link rel="stylesheet" type="text/css" href="style.css"/> <title>Database Editor</title> </head> <body> <div id="page"> <img src="images/banner1.jpg" alt="banner"/> <div id="navi-container"> <ul id="navi"> <li><a href="index.php">Home</a></li> <li><a href="news.php">News</a></li> <li><a href="latest_products.php">Latest Products</a></li> <li><a href="gallery.php">Gallery</a></li> <li><a href="Admin_page.php">Administration</a></li> </ul> </div> <?php ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <h1>Database Editor</h1> <table class="inputtable"> <tr> <td class="label">Item Name:</td> <td class="inputtd"> <input name="Item_Name" type="text" class="standardwidth" /></td> </tr> <tr> <td class="label"> Item Image:</td> <td class="inputtd"> <input name="Item_Image" type="text" class="standardwidth" /></td> </tr> <tr> <td class="label">Item Description:</td> <td class="inputtd"> <input name="Item_Description" type="text" class="standardwidth" /></td> </tr> <tr> <td class="label">Item Number:</td> <td class="inputtd"> <input name="Item_Number" type="text" class="standardwidth" /></td> </tr> </table> <br /> <table class="radbuttons"> <tr> <td class="standardwidth"> <input name="op" type="radio" checked="checked" value="rdbase" /> Read from Database</td> <td><input name="op" type="radio" value="cdbase" />Change Entry (enter data in form)</td> </tr> <tr> <td class="standardwidth"> <input name="op" type="radio" value="adbase" />Add to Database</td> <td><input name="op" type="radio" value="ddbase" />Delete Entry (enter name in form)</td> </tr> </table> <br /> <input name="submit" type="submit" value="submit" /> <input name="reset" type="reset" value="reset" /> <br /> </form> <?php if (count($view->peopleList) > 0) { ?> <table class="datatable"> <tr> <th><strong>Surname</strong></th> <th><strong>First Name </strong></th> <th class="standardwidth"><strong>Address </strong></th> <th><strong>Phone</strong></th> </tr> <?php foreach ($view->peopleList as $person) : ?> <tr> <td> <?php echo $person->getSurname(); ?> </td> <td> <?php echo $person->getFirstname(); ?> </td> <td> <?php echo $person->getAddress(); ?> </td> <td> <?php echo $person->getPhone(); ?> </td> </tr> <?php endforeach; } ?> </table> <?php ?> <?php $dbc = mysql_connect ('****','***','salford*****') OR die('Could not connect to MySQL : ' . mysql_error() ); mysql_select_db ('****') OR die('Could not select the database : ' . mysql_error() ); $query = "SELECT * FROM ****** ORDER BY Item_Number"; $result = mysql_query ($query); ?> <body> <h1>Database</h1> <table border="1"> <tbody> <tr> <td>Item Name</td> <td>Item Image</td> <td>Item Description</td> <td>Item Number</td> </tr> <?php while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { echo " <tr> <td>$row[item_Name]</td> <td>$row[item_Image]</td> <td>$row[item_Description]</td> <td>$row[item_Number]</td> </tr> "; } mysql_close(); ?> $sql = 'INSERT INTO murrayfp10_ipad (Item_Name, Item_Description, Item_Number) VALUES (:Item_Name, :Item_Description, :Item_Number)'; $result = $this->dbh->prepare($sql); $result->execute(array( ':Item_Name' => $data['Item_Name'], ':Item_Description' => $data['Item_Description'], ':Item_Number' => $data['Item_Number'] )); return $this->dbh->lastInsertId(); } public function edittbl($data) { $sql = 'UPDATE murrayfp10_ipad SET Item_Name = :Item_Name, Item_Description = :Item_Description, Item_Number = :Item_Number WHERE Item_Name = :Item_Name'; $result = $this->dbh->prepare($sql); return $result->execute(array( ':Item_Name' => $data['Item_Name'], ':Item_Description' => $data['Item_Description'], ':Item_Number' => $data['Item_Number'], ':Item_Number' => $data['Item_Number'] )); } public function deletetbl($data) { $sql = 'DELETE FROM murrayfp10_ipad WHERE Item_Name = :Item_Name'; $result = $this->dbh->prepare($sql); return $result->execute(array( ':Item_Name' => $data['Item_Name'] )); } <div style="text-align:center;"> Copyright © M.Murray 2011 </div> </body> </html>
  3. Hey guys, The email just does not want to send have you guys got any ideas why? Really frustrating but its so rewarding when it works. Thanks for you help guys
  4. Hi all, My names Mike and i am currently working on a website for my University degree but have encountered a problem when creating an email form. I have the following form below which i have created via a tutorial but it's not working i just dont recieve any emails. I would really appreciate it if someone could take a look at this for me. I must stress i am new to PHP as well. The email form just needs to state who it comes from as well as an email address and subject. code below: <html> <body> <?php if (isset($_REQUEST['email'])) //if "email" is filled out, send email { //send email $email = $_REQUEST['email'] ; $subject = $_REQUEST['subject'] ; $message = $_REQUEST['message'] ; mail("mike2fast135@hotmail.com", "$subject", $message, "From:" . $email); echo "Thank you for using our mail form"; } else //if "email" is not filled out, display the form { echo "<form method='post' action='mailform.php'> Email: <input name='email' type='text' /><br /> Subject: <input name='subject' type='text' /><br /> Message:<br /> <textarea name='message' rows='15' cols='40'> </textarea><br /> <input type='submit' /> </form>"; } ?> </body> </html> Thanks for any help or guidance. Mike
  5. Help with PHP Email Code I am currently designing a PHP website and i have been following some useful tutorials but one that i have followed i have come unstuck with and it wont work. If anyone could help me with the code below it would be a great help. First of all we have the contact.html form <html> <head> <title>Ajax Contact Form by Andrew Walsh</title> <style type="text/css"> body { margin:50px 0px; padding:0px; text-align:center; } #contactarea { width:350px; margin:0px auto; text-align:left; padding:15px; border:1px solid #333; background-color:#eee; font-weight: bold; font-family: Verdana, Arial; font-size: 12px; } #inputbox { border: 1px solid #000; width: 270; padding: 2px; font-weight: bold; font-family: Verdana, Arial; font-size: 12px; } #inputlabel { font-weight: bold; font-family: Verdana, Arial; font-size: 12px; } #textarea { border: 1px solid #000; padding: 2px; font-weight: bold; font-family: Verdana, Arial; font-size: 12px; width:330; } #submitbutton { border: 1px solid #000; background-color: #eee; } </style> <script language="javascript"> function createRequestObject() { var ro; var browser = navigator.appName; if(browser == "Microsoft Internet Explorer"){ ro = new ActiveXObject("Microsoft.XMLHTTP"); }else{ ro = new XMLHttpRequest(); } return ro; } var http = createRequestObject(); function sendemail() { var msg = document.contactform.msg.value; var name = document.contactform.name.value; var email = document.contactform.email.value; var subject = document.contactform.subject.value; document.contactform.send.disabled=true; document.contactform.send.value='Sending....'; http.open('get', 'contact.php?msg='+msg+'&name='+name+'&subject='+subject+'&email='+email+'&action=send'); http.onreadystatechange = handleResponse; http.send(null); } function handleResponse() { if(http.readyState == 4){ var response = http.responseText; var update = new Array(); if(response.indexOf('|' != -1)) { update = response.split('|'); document.getElementById(update[0]).innerHTML = update[1]; } } } </script> </head> <body> <div id="contactarea"> <form name="contactform" id="contactform"> <span id="inputlabel">Name:</span> <input type="text" name="name" id="inputbox"> <span id="inputlabel">Email:</span> <input type="text" name="email" id="inputbox"> <span id="inputlabel">Subject:</span> <input type="text" name="subject" id="inputbox"> <span id="inputlabel">Message:</span> <textarea name="msg" rows="10" id="textarea"></textarea> <input type="button" value="Send Email" name="send" onclick="sendemail();" id="submitbutton"> </form> </div> </body> </html> Then we have the contact.php form <?php /* Author: Andrew Walsh Date: 30/05/2006 Codewalkers_Username: Andrew This script is a basic contact form which uses AJAX to pass the information to php, thus making the page appear to work without any refreshing or page loading time. */ $to = "mike2fast135@hotmail.com"; //This is the email address you want to send the email to $subject_prefix = ""; //Use this if you want to have a prefix before the subject if(!isset($_GET['action'])) { die("You must not access this page directly!"); //Just to stop people from visiting contact.php normally } /* Now lets trim up the input before sending it */ $name = trim($_GET['name']); //The senders name $email = trim($_GET['email']); //The senders email address $subject = trim($_GET['subject']); //The senders subject $message = trim($_GET['msg']); //The senders message mail($to,$subject,$message,"From: ".$email.""); //a very simple send echo 'contactarea|Thank you '.$name.', your email has been sent.'; //now lets update the "contactarea" div on the contact.html page. The contactarea| tell's the javascript which div to update. ?> From what i can gather the HTML form passes the information to the PHP form which then sends the information to your email address. I have changed the email address to the one that i want to use and have also tried using a different one incase it did not like the one i have chosen to use. If anyone could help with this i would really appreciate it. Thanks Posts: 1 Joined: Thu Mar 31, 2011 12:03 pm Top
×
×
  • 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.