Jump to content

derekbelcher

Members
  • Posts

    70
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

derekbelcher's Achievements

Member

Member (2/5)

0

Reputation

  1. My apologies. The links now work. I forgot to upload the files. I am also posting the code below. The first code is for the page the user sees. The second is the page that makes it all work. I think. What I am hoping is that someone with experience can take a look and say "This is why your data isn't making it to the databse" I am not a programmer and really have no idea what I am looking at. Just hoping for a quick fix. Thanks <?php session_start(); if (!ISSET($_SESSION["uid"])) { header( 'LOCATION OF THE WEBSITE HOME PAGE' ) ; } ?> <!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 http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Goshen Sparkling Jewelry - Princeton, WV | (304) 555-5555</title> <link href="/css/goshenMain.css" rel="stylesheet" type="text/css" /> <link href="/css/wt-rotator.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> function updateAlert() { var xmlhttp; var alerttext = document.getElementById("alerttext").value; var alerttype = document.getElementById("alerttype").value; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("alertarea").innerHTML = xmlhttp.responseText; alert("Alert Successfully Updated."); } } xmlhttp.open("POST","alertupdate.php",true); xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xmlhttp.send("alert="+alerttext+"&alerttype="+alerttype); } function clearAlert() { document.getElementById("alerttext").value = ''; document.getElementById("alerttype").value = 1; updateAlert(); } </script> </head> <body> <div class="container"> <div class="navigation"> <div style="float:left"><a href="?pid=0"><img src="images/template/Logo.gif" border="0" width="398" /></a></div> <div style="float:left"><img src="images/template/logo_right.gif" height="145" width="602" border="0" /></div> </div> <div style="clear:both"></div> <!--Close Navigation--> <div class="content"> <div id="alertarea" class="mainText"> <?php $link = mysql_connect('localhost', 'USERNAME', 'PASSWORD'); if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db('DATABASE'); //First we need to check for an existing demographic record. $alert_result = mysql_query("SELECT * FROM alerts LIMIT 1"); while($row = mysql_fetch_array($alert_result)) { $alert = $row["content"]; $type = $row["type"]; } ?> <table width="799" border="0" cellpadding="0" cellspacing="0" align="center" bgcolor="#ffffff"> <tr> <td width="799" valign="top" style="background:#FFFFFF" align="center"><b>Promotion Alert Text</b><br></td> </tr> <tr> <td width="799" align="center" style="background:#FFFFFF" ></td> </tr> <tr> <td valign="middle" width="799" align="center" style="background:#FFFFFF" > <textarea name="alerttext" id="alerttext" cols="80" rows="5"><?php echo $alert; ?></textarea> </td> </tr> <tr> <td valign="middle" width="799" align="center" style="background:#FFFFFF" > </td> </tr> <tr> <td valign="middle" width="799" align="center" style="background:#FFFFFF" > Type of Promotion: <select id="alerttype" name="alerttype"> <? if ($type == 1) { print('<option selected value="1">% or $ off</option>'); } else { print('<option value="1">% or $ off</option>'); } if ($type == 2) { print('<option selected value="2">BOGO</option>'); } else { print('<option value="2">BOGO</option>'); } if ($type == 3) { print('<option selected value="3">Shipping</option>'); } else { print('<option value="3">Shipping</option>'); } ?> </select> </td> </tr> <tr> <td valign="middle" width="799" align="center" style="background:#FFFFFF" > </td> </tr> <tr> <td valign="middle" width="799" align="center" style="background:#FFFFFF" > <input type="button" name="updatebtn" id="updatebtn" value="Update Alert" onClick="updateAlert();"> <input type="button" name="clearbtn" id="clearbtn" value="Clear Alert" onClick="clearAlert();"> </td> </tr> </table> </div> </div><!--Close Content--> <div class="footer"> <div style="float:left"><img src="images/template/footer.gif" height="81" width="435" border="0" alt="footer"></div> <div style="float:left"><a href="?pid=1"><img src="images/template/footer_build.gif" border="0" alt="Build Your Own" /></a><a href="?pid=2"><img src="images/template/footer_premade.gif" border="0" alt="Premade Items" /></a><a href="?pid=3"><img src="images/template/footer_special.gif" border="0" alt="Special Deals" /></a><a href="?pid=4"><img src="images/template/footer_sitemap.gif" border="0" alt="Sitemap and FAQ" /></a><a href="?pid=5"><img src="images/template/footer_contact.gif" alt="Contact Us" border="0" /></a><a href="?pid=6"><img src="images/template/footer_terms.gif" border="0" alt="Terms and Conditions" /></a></div><div style="float:right"><img src="images/template/footer_linksBottom.gif" border="0" /><a href="/login.php"><img src="images/template/login.gif" /></a></div> <div style="clear:both"></div> </div><!--Close Footer--> </div><!--Close Main Container--> </body> </html> Second page: <? $alert = $_POST["alert"]; $alerttype = $_POST["alerttype"]; $link = mysql_connect('localhost', 'USERNAME', 'PASSWORD'); if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db('DB NAME'); mysql_query("UPDATE alerts SET content = '".$alert."', type=".$alerttype." WHERE id = 1"); //First we need to check for an existing demographic record. $alert_result = mysql_query("SELECT * FROM alerts LIMIT 1"); while($row = mysql_fetch_array($alert_result)) { $alert = $row["content"]; $type = $row["type"]; } ?> <table width="799" border="0" cellpadding="0" cellspacing="0" align="center" bgcolor="#ffffff"> <tr> <td width="799" valign="top" style="background:#FFFFFF" align="center"><b>Promotion Alert Text</b><br></td> </tr> <tr> <td width="799" align="center" style="background:#FFFFFF" ></td> </tr> <tr> <td valign="middle" width="799" align="center" style="background:#FFFFFF" > <textarea name="alerttext" id="alerttext" cols="80" rows="5"><?php echo $alert; ?></textarea> </td> </tr> <tr> <td valign="middle" width="799" align="center" style="background:#FFFFFF" > </td> </tr> <tr> <td valign="middle" width="799" align="center" style="background:#FFFFFF" > Type of Promotion: <select id="alerttype" name="alerttype"> <? if ($type == 1) { print('<option selected value="1">% or $ off</option>'); } else { print('<option value="1">% or $ off</option>'); } if ($type == 2) { print('<option selected value="2">BOGO</option>'); } else { print('<option value="2">BOGO</option>'); } if ($type == 3) { print('<option selected value="3">Shipping</option>'); } else { print('<option value="3">Shipping</option>'); } ?> </select> </td> </tr> <tr> <td valign="middle" width="799" align="center" style="background:#FFFFFF" > </td> </tr> <tr> <td valign="middle" width="799" align="center" style="background:#FFFFFF" > <input type="button" name="updatebtn" id="updatebtn" value="Update Alert" onClick="updateAlert();"> <input type="button" name="clearbtn" id="clearbtn" value="Clear Alert" onClick="clearAlert();"> </td> </tr> </table>
  2. Hey there. I have a website that has been "dumped" in my lap as my programmer has journeyed to greener pastures. We have a small form that collects a little data and supposedly inserts it into the database, but for some reason that data never makes it there. You can get the two pages that contain the code: http://dev.goshensparklingjewelry.com/page_1.txt is the page that the user goes to to insert the data, and http://dev.goshensparklingjewelry.com/page_2.txt is the magic page that makes it happen. Not sure what is going on. When you submit the data, you even get the success page as if it went through alright. There is also a place in there that reads and displays data that is already in there, and that part works as well. thanks!
  3. Thank you netaneledri! I appreciate you bailing me out here. We are working out an agreement with a new tech firm to manage this stuff, but I had a client in need in the interim. Total Lifesaver. I had a feeling it was something small, but just don't know how to read the code. Thanks again!
  4. I am in desperate need of assistance with an inherited script from a "no-longer-works-with-me" website desiger. Long story short, my web developer left for another job and I have a script that a client is having trouble with. This script allows the admin to upload a new member's name, title, and picture. The picture is inserted into a file on the server. The problem is that the file is inserted with a default permission of 600 which does not allow the pic to be viewed on the public facing website or the admin page. I have read that chmod may be my answer, but am not a programmer by any means and have no idea where to implement this fix. I have attached the code as a .txt file - its the full code that resides on this page. Any help is greatly appreciated. code.txt
  5. not sure what that means. The email function is working. I am getting data, but I just want to format how it looks.
  6. Hi, I am using a form to collect text data, and then spitting it out in an email. I need help formatting the way it looks in the email. How can I modify the following code so that it displays with the name of the award in the left cell and the winner (collected from the form) in the right cell. Left cell should justify to the right and right cell justify to the left and be bold. Any help would be great. Thanks. $message = "A nomination form has been received. Nominees are:\r\n\r\n"; $message .= "Ray O. Duncan Award: $duncan\r\n\r\n"; $message .= "Honor Award: $honor\r\n\r\n"; $message .= "Young Professional Award: $young\r\n\r\n"; $message .= "Bea N. Orr Student Award: $orr\r\n\r\n"; $message .= "Scholar Award: $scholar\r\n\r\n"; $message .= "Ethnic Minority Grad Fellow Award: $gradfellow\r\n\r\n"; $message .= "Recreation/Leisure Leadership Award: $rec\r\n\r\n"; $message .= "Elementary Teacher of the Year: $etoy\r\n\r\n"; $message .= "Middle School Teacher of the Year: $mtoy\r\n\r\n"; $message .= "High School Teacher of the Year: $htoy\r\n\r\n"; $message .= "K12 Dance Educator of the Year: $danceEd\r\n\r\n"; $message .= "Health Educator of the Year: $health\r\n\r\n";
  7. I am using a database with page id (pid) and a field that is designated as type=longtext. In that field I am putting all my html code and then calling that page id with a simple query. Now the problem. The page where this simple query is located won't process the content if it contains php. I tried a very simple example: <?php Print "Hello, World!"; ?> If I just type in Hello World in the database table, it displays fine on the webpage, but if I try to do it as php, it doesn't display What am I missing. Code that calls the querry: <? $conn = mysql_connect('localhost','dbelcher','wvmcs2009'); mysql_select_db($wvmcsContent, $conn); mysql_select_db('wvmcsContent', $conn) or die( "Unable to select database"); $query="SELECT contenttext FROM content WHERE id = $pid"; $result=mysql_query($query); mysql_close(); $contenttext=mysql_result($result,0,"contenttext"); print("$contenttext"); ?> Information I want to display is in the "content" table in the field, contenttext. Any help?
  8. Hello. I have a form that asks the user to enter several different times. I want them to be able to enter it as a straight four digit number. For example: 1534. Then I want that to convert to 15 hours and 34 minutes in the database Also, is there a way to format the text box so that when they move to the next box it displays as 15:34 instead of 1534. Not sure where to go here????
  9. Hi. I am trying to create a small area on my website where folks can upload a jpg or gif photo to a designated spot on the server. I have my db set up so that the field is set to BLOB. What i need is the php code to put on the site so that when the user browses for the photo and selects it and hits upload it actually goes on the server. any help?
  10. In this code, where would I use this? I am just not sure where to place the getImagesize...thanks for your help. <?php //This is the directory where images will be saved $target = "images/"; $target = $target . basename( $_FILES['photo']['name']); //This gets all the other information from the form $caption=$_POST['caption']; $pic=($_FILES['photo']['name']); // Connects to your Database mysql_connect("--------") or die(mysql_error()); mysql_select_db("p2r71184_photos") or die(mysql_error()) ; //Writes the information to the database mysql_query("INSERT INTO `athensPhoto` (caption, photo) VALUES ('$caption', '$pic')"); //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { header('location:viewphoto.php'); //Tells you if its all ok echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } ?>
  11. I am trying to tweak a photo upload code so that my users can only upload a certain file type (gif, jpg, jpeg) and a max size of 240 x 160 px. I think I can do this somehow after I pass the upload to the server in a temp. state before it is moved to it's final state in the db. What should I do?
  12. What a bone head error. Adding the column names worked like a charm. Thanks so much.
  13. I am working on a photo upload script. I can get the photos into the database but only if there is no primary key turned on. When I use "id" set to an int as the primary key, the data will not store from the form. Here is my "add.php" script. Is there something that I can add to have it reference or work with "id". I need to do this so I can make it functional with a "delete" and "edit" script I have already written. I just can't put my finger on it. <?php //This is the directory where images will be saved $target = "images/"; $target = $target . basename( $_FILES['photo']['name']); //This gets all the other information from the form $caption=$_POST['caption']; $pic=($_FILES['photo']['name']); // Connects to your Database mysql_connect("Localhost", "p2r71184", "692134a") or die(mysql_error()); mysql_select_db("p2r71184_photos") or die(mysql_error()) ; //Writes the information to the database mysql_query("INSERT INTO `athensPhoto` VALUES ('$caption', '$pic')"); //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { header('location:viewphoto.php'); //Tells you if its all ok echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } ?> EDITED BY akitchin: code tags. use them.
  14. I am writing a php script to handle photo uploads. I got the script to work, but the data is in the wrong fields. I have a field for "caption" and a field for the photo. This is causing the output to show a broken link for the photo. here is the code: <?php //This is the directory where images will be saved $target = "images/"; $target = $target . basename( $_FILES['photo']['name']); //This gets all the other information from the form $caption=$_POST['caption']; $pic=($_FILES['photo']['name']); // Connects to your Database mysql_connect("Localhost", "p2r71184", "692134a") or die(mysql_error()); mysql_select_db("p2r71184_photos") or die(mysql_error()) ; //Writes the information to the database mysql_query("INSERT INTO `athensPhoto` VALUES ('$caption', '$pic')"); //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //Tells you if its all ok echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } ?>
  15. FILES:Array ( [photo] => Array ( [name] => Untitled-2.jpg [type] => image/jpeg [tmp_name] => /tmp/phpFDLJZ5 [error] => 0 => 7574 ) ) Does this make any since? thanks for your 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.