PHP - Php Help Desparately Requested
The attached code pulls data from a mysql database & displays it in a form so I can edit it. I need to be able, when a user clicks the submit button in this code, the data is updated in the mysql database, and sends that data to an email address based off of the location. At this time I just have first name, lastname, and location in there. So if a user chose office1 the data would go to office1@mail.com. Everything works except the email part.
I thought I had it earlier but was wrong. Can someone please assist? Thanks Code: [Select] <?php # edit_dqa.php $page_title = 'Edit a Record'; $con = mysql_connect("localhost","uname","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("psrflow", $con); if ( (isset($_GET['id'])) && (is_numeric($_GET['id'])) ) { // Accessed through view_users.php $id = $_GET['id']; } elseif ( (isset($_POST['id'])) && (is_numeric($_POST['id'])) ) { // Form has been submitted. $id = $_POST['id']; } else { // No valid ID, kill the script. echo '<h1 id="mainhead">Page Error</h1> <p class="error">This page has been accessed in error.</p><p><br /><br /></p>'; include ('./includes/footer.html'); exit(); } $query = "UPDATE psrinfo SET fname='$fn', lname='$ln', location='$loc' WHERE fid=$id"; $result = @mysql_query ($query); // Run the query. // Send mail according to location switch($_REQUEST['location']) { case "office1": $email = "myemail@yahoo.com"; break; default: echo "Error, no location selected!!!"; break; } $Message = "<p>An employee has edited the information below.</p><br> Location : {$_REQUEST['location']}<br>First Name : {$_REQUEST['fname']}<br>Last Name : {$_REQUEST['lname']}"; $Headers = "MIME-Version: 1.0\n"; $Headers .= "Content-type: text/html; charset=iso-8859-1\n"; $Subject = "Please Review"; $Headers .= "To: DQA <$EmailAddress>\n"; $Headers .= "From: The Database <sender email>\n"; $SendMail = mail($EmailAddress, $Subject, $Message, $Headers); if (mail($EmailAddress, $Subject, $Message, $Headers)) { echo "<center>An email has been sent for editing"; } else { echo "This system is not working properly. Please contact a tech."; } $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); if ((substr($url, -1) == '/') OR (substr($url, -1) == '//')) { $url = substr ($url, 0, -1); } $url ='/flow/index.html'; header("Location: $url"); exit(); } else { // Report the errors. echo '<h1 id="mainhead">Error!</h1> <p class="error">The following error(s) occurred:<br />'; foreach ($errors as $msg) { // Print each error. echo " - $msg<br />\n"; } echo '</p><p>Please try again.</p><p><br /></p>'; } // End of if (empty($errors)) IF. } // End of submit conditional. // Retrieve the user's information. $query = "SELECT pacts, fname, lname, location WHERE fid = " . $_REQUEST['id']; $result = @mysql_query ($query); // Run the query. if (mysql_num_rows($result) == 1) { // Valid user ID, show the form. $row = mysql_fetch_array ($result, MYSQL_NUM); ?> <?php echo '<form action="edit_dqa.php" method="post"> <fieldset><legend><h1> You are editing a record!</h1></legend> <b>First Name:</b> <br><input type="text" name="fname" size="15" maxlength="30" value="'.$row[1].'" /><br /> <b>Last Name:</b> <br><input type="text" name="lname" size="15" maxlength="30" value="'.$row[2].'" /><br /> <b>Location: </b><br><input type="text" name="location" size="15" maxlength="30" value="'.$row[5].'" /><br> br> <br> </fieldset> <div align="left"><input type="submit" name="submit" value="Submit" /></div> <input type="hidden" name="submitted" value="TRUE" /> <input type="hidden" name="id" value="' . $id . '" /> </form>'; } else { // Not a valid user ID. echo '<h1 id="mainhead">Page Error</h1> <p class="error">This page has been accessed in error.</p><p><br /><br /></p>'; } mysql_close(); // Close the database connection. ?> Similar TutorialsI have a mysql database. I have some PHP code that I can view the mysql data & add data to the mysql database. I've attached a photo to look at. You will see an "Edit" button at the end. I need to be able to click on the edit button & it will bring up another page so I can edit that particular record. I do have an ID field in the mysql database that is set to auto inrement so each record has it's own ID. I have no clue where to start as I know very little about PHP. The mysql database name is flow & the table name is info. The fields in the database that you see in the photo is due_ge, due_ny, and due_rk. The page I go to view the data in the mysql database is named view.php & the file I use to enter a new record is named add.php. If I could click the "edit" button to somehow edit these date fields that would be great!! Could someone start me in the right direction? I want to make an image that will get the url that the php image was requested from... I read the manual for the _SERVER superglobal, but I am still not clear on which element will do that. Thanks. The attached code works but I have one issue. When I type in a date for the fields "Submitted to Office" or "Submitted to Supervisor" in the format 2011-05-05 & then click the submit button, it gets entered into my MySQL databse correctly. My question is, is there any way to edit this code so the user will get a pop up box if the enter a date other than in the format YYYY-MM-DD? Basically, I want them to enter it as YYYY-MM-DD so it will update the MySQl database like it is supposed to. Code: [Select] <b> <p> <i> To go to the main page <a href="http://tnep-g-psrflow/flow/index.html">click here</a>.</p> </i> <?php # edit_dqa.php $page_title = 'Edit a Record'; $con = mysql_connect("localhost","username","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("psrflow", $con); ini_set('display_errors',1); error_reporting(E_ALL); if ( (isset($_GET['id'])) && (is_numeric($_GET['id'])) ) { $id = $_GET['id']; } elseif ( (isset($_POST['id'])) && (is_numeric($_POST['id'])) ) { $id = $_POST['id']; } else { // No valid ID, kill the script. echo '<h1 id="mainhead">Page Error</h1> <p class="error">This page has been accessed in error.</p><p><br /><br /></p>'; include ('./includes/footer.html'); exit(); } if (isset($_POST['submitted'])) { $errors = array(); if (empty($_POST['pacts'])) { $errors[] = 'You forgot to enter your PACTS number. If there is no PACTS # you can enter 0000'; } else { $pt = $_POST['pacts']; } if (empty($_POST['fname'])) { $errors[] = 'You forgot to enter the first name.'; } else { $fn = $_POST['fname']; } if (empty($_POST['lname'])) { $errors[] = 'You forgot to enter the last name.'; } else { $ln = $_POST['lname']; } if (empty($_POST['date_sub_crt'])) { $errors[] = 'You forgot to enter a date submitted to office!.'; } else { $crt = $_POST['date_sub_crt']; } if (empty($_POST['date_disclo_att'])) { $errors[] = 'You forgot to enter the supervisor disclosure date!'; } else { $disc = $_POST['date_disclo_att']; } if (empty($errors)) { $query = "UPDATE psrinfo SET pacts='$pt', fname='$fn', lname='$ln', date_sub_crt='$crt', date_disclo_att='$disc' WHERE fid=$id"; $result = @mysql_query ($query); // Run the query. $EmailAddress = 'email@yahoo.com'; $Message = "A clerk has entered a 'Date Submitted to supervisor or office'. Please enter/edit this information in PACTS.\n \n PACTS No : ${_REQUEST['pacts']}\n First Name : ${_REQUEST['fname']} \n Last Name : ${_REQUEST['lname']} \n Date Submitted to office : ${_REQUEST['date_sub_crt']} \n Date Dislosed to supervisor : ${_REQUEST['date_disclo_att']} "; $Subject = "A Clerk has Edited a Record."; $Headers = "From: PODDS@yahoo.com \n"; if (mail($EmailAddress, $Subject, $Message, $Headers)) { echo "<p><center><h2>My Office</h2></center></p>"; echo "<p><h3><center>Eastern District</center></h3></p>"; echo "<center>An email has been sent to your supervisor for approval and "; } else { echo "This system is not working properly. Please contact IT so they can fix it."; } $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); if ((substr($url, -1) == '/') OR (substr($url, -1) == '//')) { $url = substr ($url, 0, -1); } $url ='/flow/index.html'; header("Location: $url"); exit(); } else { // Report the errors. echo '<h1 id="mainhead">Error!</h1> <p class="error">The following error(s) occurred:<br />'; foreach ($errors as $msg) { // Print each error. echo " - $msg<br />\n"; } echo '</p><p>Please try again.</p><p><br /></p>'; } } $query = "SELECT pacts, fname, lname, date_sub_crt, date_disclo_att, date_disclo_att FROM psrinfo WHERE fid = " . $_REQUEST['id']; $result = @mysql_query ($query); // Run the query. if (mysql_num_rows($result) == 1) { $row = mysql_fetch_array ($result, MYSQL_NUM); ?> <?php echo '<form action="clerk_edit.php" method="post"> <fieldset><legend><h2> You are editing a record! After submitting this form, your DQA will be notified of the change via email.</h2></legend> <b>PACTS No:</b> <br><input type="text" name="pacts" size="15" maxlength="30" value="'.$row[0].'" /><br> <b>First Name:</b> <br><input type="text" name="fname" size="15" maxlength="30" value="'.$row[1].'" /><br /> <b>Last Name:</b> <br><input type="text" name="lname" size="15" maxlength="30" value="'.$row[2].'" /><br /> <b>Submitted to office: </b><br><input type="text" name="date_sub_crt" size="15" maxlength="30" value="'.$row[3].'" /> <br> <b>Submitted to supervisor: </b><br><input type="text" name="date_disclo_att" size="15" maxlength="30" value="'.$row[4].'" /> <br> </fieldset> <div align="left"><input type="submit" name="submit" value="Submit" /></div> <input type="hidden" name="submitted" value="TRUE" /> <input type="hidden" name="id" value="' . $id . '" /> </form>'; } else { // Not a valid user ID. echo '<h1 id="mainhead">Page Error</h1> <p class="error">This page has been accessed in error.</p><p><br /><br /></p>'; } mysql_close(); // Close the database connection. ?> This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=352271.0 Working on a site with a couple hundred virtually identical landing pages to maximize SEO. Rather than hard code the pages, I am wondering if there is a way to have one page that handles all the url's and dynamically codes and loads with title, keywords, content & alt tags all specific to the particular url requested. Seems like the challenge is doing it in a way that does not constitute a redirect. Is it better to do this in the .htaccess? Hi there guys I have a problem that I can't seem to get fixed.
Below Is the code I am using and the Link to the Tutorial:
http://fearlessflyer...x-and-timthumb/
$to=sammieave@ave.com,samuel@ave.com; $subject = "New Event Logged"; $message = "Test"; $headers = "From: Samuel<sammieave@ave.com>;\r\n"; $headers .= "Content-Type: text/html"; mail($to,$subject,$message,$headers); I am having the above code but unfortunately the error I am getting is: Warning: mail() [function.mail]: SMTP server response: 550 Requested action not taken: mailbox unavailable or not local in C:\xampp\htdocs\CRM\support\mailer.php on line 139 Hello! I have the following php code: Code: [Select] <?php // The message $message = "[request("Id_From")]\n [request("ID")]\n [request("CUT")]\n [request("MAKE")]\n [request("CARAT")]\n [request("PRICE_PC")]\n [request("CLARITY")]\n [request("LOCATION")]\n [request("CERTIFICATE")]\n [request("SUP_STOCK_REF")]\n [request("Measurements")]\n [request("Total_Depth")]\n [request("Polish")]\n [request("Table_Width")]\n [request("Symmetry")]\n [request("Crown_Height")]\n [request("Culet")]\n [request("Parillion_Depth")]\n [request("Graining")]\n [request("Girdle")]\n [request("Remarks")]\n [request("TotalPrice")]"; // In case any of our lines are larger than 70 characters, we should use wordwrap() $message = wordwrap($message, 70); // Send mail('gary.impact@gmail.com', 'HIGH PRIORITY DIAMOND ORDER!', $message); ?> where I am trying to send an email to myself which will send me the listed 'requested' values. These values are to the script in the form of: Code: [Select] http://www.somedomain.com/somepage.html?Id_From=123&ID=50250430&CUT=Round&MAKE=VG+-+G++++&CARAT=.5&PRICE_PC=5719&COLOR=D&CLARITY=VVS1&LOCATION=California+%28U.S.A.%29&CERTIFICATE=GIA&SUP_STOCK_REF=3540-6&Measurements=5.03x5.08x3.17&Total_Depth=62.7%25&Polish=V.good&Table_Width=60%25&Symmetry=Good&Crown_Height=&Culet=None&Parillion_Depth=&Graining=&Girdle=&Fluorescence=None&Remarks=&TotalPrice=2860 I am getting the error: Code: [Select] Parse error: syntax error, unexpected T_STRING Which starts on the first line of my requested data ("[request("Id_From")]\n). Any help on this would be truely appreciated! Thank you! |