Jump to content

Theora

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Theora's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I'm relatively new to php so I may not have been using the correct terminology when searching for an answer to this question. Any help you can give or pointers in the right direction would be greatly appreciated! I have a form that's created using the variable "$days". The code for the table rows withing the form looks something like this: $i = 1; while ($i <= $days): echo " <tr> <td><input name=\"date$i\" type=\"text\" size=\"10\" /></td> <td><input name=\"location$i\" type=\"text\" size=\"25\" /></td> <td><input name=\"hours$i\" type=\"text\" size=\"5\" /></td> </tr> "; $i++; endwhile; The form gets sent to a php file that uses the mail() function. If it were to just send one row of data, it would look like this: <?php @extract($_POST); $date = stripslashes($date); $location = stripslashes($location); $hours = stripslashes($hours); mail('address@wherever.com',"subject line","$date: $location ($hours hours)"); header("location:whereit'sredirected.php"); ?> What I want it to do -- and I don't know if it's even possible -- is to have it get the value of $days (let's say 3 for now) and create variables $date1, $date2, $date3, $location1, $location2, $location3, etc. And, even if it's possible to do that, how would you then work the text area of the mail to let it know how many variables there were? Thanks in advance!
  2. I'm having difficulty with a search page. I followed the instructions in the Dreamweaver Help under "Building search/results pages (ColdFusion, ASP, JSP, PHP)", but it seems like the recordset is not recognizing the variables that are coming from the form. The variables [b]are[/b] being passed to the page; I put in a simple "echo($_REQUEST['varFamily']);" line and they show up. Below is the code being used for the form (most options have been cut for the sake of brevity): [code] <form action="searchresults.php" method="post" name="searchform" id="searchform">     <p>Fixture Family:<br />       <select name="varFamily" id="varFamily">         <option value="" selected="selected">choose family...</option>         <option value="Avalon">Avalon</option>         <option value="Carriage Hills">Carriage Hills</option>         <option value="Centennial PW">Centennial PW</option>       </select>     </p>     <p>Fixture Finish:<br />       <select name="varFinish" id="varFinish">         <option value="" selected="selected">choose finish...</option>         <option value="Antique Silver Crackle">Antique Silver Crackle</option>         <option value="Burnt Sienna">Burnt Sienna</option>       </select>     </p>     <p>Fixture Type:<br />       <select name="varType" id="varType">         <option value="" selected="selected">choose type...</option>         <option value="Accessories">Accessories</option>         <option value="Bath Fixture">Bath Fixture</option>       </select>     </p>     <p>Item Number:<br />       <input name="itemnumber" type="text" id="itemnumber" />     </p>     <p>     <input type="submit" name="Submit" value="Search" />   </p> </form> [/code] Here's a screenshot of the recordset window... [url=http://img68.imageshack.us/img68/6353/recordsetbx3.gif]http://img68.imageshack.us/img68/6353/recordsetbx3.gif[/url] ...and following is the code it generates: [code] $varFinish_rs_getSearchResults = "%"; if (isset($HTTP_POST_VARS['varFinish'])) {   $varFinish_rs_getSearchResults = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS['varFinish'] : addslashes($HTTP_POST_VARS['varFinish']); } $varType_rs_getSearchResults = "%"; if (isset($HTTP_POST_VARS['varType'])) {   $varType_rs_getSearchResults = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS['varType'] : addslashes($HTTP_POST_VARS['varType']); } $varItemNumber_rs_getSearchResults = "%"; if (isset($HTTP_POST_VARS['varItemNumber'])) {   $varItemNumber_rs_getSearchResults = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS['varItemNumber'] : addslashes($HTTP_POST_VARS['varItemNumber']); } $varFamily_rs_getSearchResults = "%"; if (isset($HTTP_POST_VARS['varFamily'])) {   $varFamily_rs_getSearchResults = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS['varFamily'] : addslashes($HTTP_POST_VARS['varFamily']); } mysql_select_db($database_conn_catalog, $conn_catalog); $query_rs_getSearchResults = sprintf("SELECT * FROM catalog WHERE family LIKE '%s' AND fixturefinish LIKE '%s' AND fixturetype LIKE '%s' AND itemnumber LIKE '%s'", $varFamily_rs_getSearchResults,$varFinish_rs_getSearchResults,$varType_rs_getSearchResults,$varItemNumber_rs_getSearchResults); [/code] Any ideas what I'm doing wrong? Thanks in advance!
  3. I'm trying to allow someone to update a record (using the Update Record server behavior in Dreamweaver 8 ) and upon completion redirect to the page "admin.php". For some reason when the submit button is pressed the page simply reloads and the fields contain the original information with all changes lost. Any idea what's going wrong? Thanks... following is the code. [code] <?php require_once('Connections/content.php'); ?> <?php function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") {   $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;   switch ($theType) {     case "text":       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";       break;        case "long":     case "int":       $theValue = ($theValue != "") ? intval($theValue) : "NULL";       break;     case "double":       $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";       break;     case "date":       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";       break;     case "defined":       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;       break;   }   return $theValue; } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) {   $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "updating")) {   $updateSQL = sprintf("UPDATE content SET primary_con=%s, pagecontent_con=%s, updated_con=%s WHERE pagename_con=%s",                       GetSQLValueString($_POST['key'], "int"),                       GetSQLValueString($_POST['textarea'], "text"),                       GetSQLValueString($_POST['updated'], "date"),                       GetSQLValueString($_POST['pagename'], "text"));   mysql_select_db($database_content, $content);   $Result1 = mysql_query($updateSQL, $content) or die(mysql_error());   $updateGoTo = "admin.php";   if (isset($_SERVER['QUERY_STRING'])) {     $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";     $updateGoTo .= $_SERVER['QUERY_STRING'];   }   header(sprintf("Location: %s", $updateGoTo)); } $colname_rsEdit = "-1"; if (isset($_GET['recordID'])) {   $colname_rsEdit = (get_magic_quotes_gpc()) ? $_GET['recordID'] : addslashes($_GET['recordID']); } mysql_select_db($database_content, $content); $query_rsEdit = sprintf("SELECT * FROM content WHERE pagename_con = '%s'", $colname_rsEdit); $rsEdit = mysql_query($query_rsEdit, $content) or die(mysql_error()); $row_rsEdit = mysql_fetch_assoc($rsEdit); $totalRows_rsEdit = mysql_num_rows($rsEdit); ?> <!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>Untitled Document</title> </head> <body> <form id="updating" name="updating" method="POST" action="<?php echo $editFormAction; ?>">   <table width="500" border="0" align="center" cellpadding="15" cellspacing="0">     <tr>       <td><input name="key" type="hidden" id="key" value="<?php echo $row_rsEdit['primary_con']; ?>" />         <input name="pagename" type="hidden" id="pagename" value="<?php echo $row_rsEdit['pagename_con']; ?>" />         Updating <?php echo ucfirst($row_rsEdit['pagename_con']); ?></td>     </tr>     <tr>       <td><textarea name="textarea" cols="55" rows="20"><?php echo $row_rsEdit['pagecontent_con']; ?></textarea></td>     </tr>     <tr>       <td><input name="updated" type="hidden" id="updated" value="<?php echo $row_rsEdit['updated_con']; ?>" />       <input name="Update" type="submit" id="Update" value="Submit" /></td>     </tr>   </table>   <input type="hidden" name="MM_update" value="updating"> </form> </body> </html> <?php mysql_free_result($rsEdit); ?> [/code]
  4. I'm trying to set up something that should be relatively simple; one page where the user selects the item they would like to update which passes them on to a second page where the record they selected is available for editing. I attempted to follow the instructions at livedocs.macromedia.com, but the second page isn't bringing up the selected record. This is what I have: Page 1: [code]<table width="300" border="0" align="center" cellpadding="5">   <tr>     <td>Which page would you like to edit? </td>   </tr>   <?php do { ?>     <tr>       <td><a href="edit.php?recordID=<?php echo $row_rsContent['pagename_con']; ?>"><?php echo $row_rsContent['pagename_con']; ?></a></td>     </tr>     <?php } while ($row_rsContent = mysql_fetch_assoc($rsContent)); ?> </table>[/code] This part seems to work fine. When the next page comes up the url ends with ?recordID=main (for example). The code for the second page: [code] <?php require_once('Connections/content.php'); ?> <?php $colname_rsEdit = "-1"; if (isset($_GET['id'])) {   $colname_rsEdit = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']); } mysql_select_db($database_content, $content); $query_rsEdit = sprintf("SELECT primary_con, pagename_con, pagecontent_con FROM content WHERE pagename_con = '%s'", $colname_rsEdit); $rsEdit = mysql_query($query_rsEdit, $content) or die(mysql_error()); $row_rsEdit = mysql_fetch_assoc($rsEdit); $totalRows_rsEdit = mysql_num_rows($rsEdit); ?> <!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>Untitled Document</title> </head> <body> <form id="updating" name="updating" method="post" action="">   <table width="500" border="0" align="center" cellpadding="15" cellspacing="0">     <tr>       <td>Updating <?php echo ucfirst($row_rsEdit['pagename_con']); ?></td>     </tr>     <tr>       <td><textarea name="textarea" cols="55" rows="20"><?php echo $row_rsEdit['pagecontent_con']; ?></textarea></td>     </tr>     <tr>       <td><input name="Update" type="submit" id="Update" value="Submit" /></td>     </tr>   </table> </form> </body> </html> <?php mysql_free_result($rsEdit); ?> [/code] It appears (to my untrained eye) that there is a query to select three things where the page name equals the variable passed from the previous page. It also appears that the large text area is trying to call in the contents of "pagecontent." I've tried both the quick (using the wizard) and step-by-step methods given on the Macromedia site and get the same results. Can you see what I'm doing incorrectly here? Thanks!
×
×
  • 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.