Jump to content

bryanptcs

Members
  • Posts

    49
  • Joined

  • Last visited

    Never

Everything posted by bryanptcs

  1. I have a contact form and it used to work. I think I might have changed versions of php but I am not sure what I had before. It is now running 5.1.6, here is the php code for the form. This is the error I am getting, it is from the last line of the PHP code: "Error: Please press back on your browser and try again." <?php $EmailTo = "bryanedwards05@gmail.com"; $contactsubject= Trim(stripslashes ($_POST['subject'])); $Name= Trim(stripslashes ($_POST['name'])); $HomeTel= Trim(stripslashes ($_POST['phone'])); $Email= Trim(stripslashes ($_POST['email'])); $Message= Trim(stripslashes ($_POST['message'])); $EmailFrom = $Email; // validation $validationOK=true; if (Trim($Name)=="") $validationOK=false; if (Trim($contactsubject)=="") $validationOK=false; if (Trim($Email)=="") $validationOK=false; if (Trim($Message)=="") $validationOK=false; if (!$validationOK) { echo "The form was not properly sent, please press back on your browser and make sure all required feilds are entered and try again. Thank you."; exit; } $Subject = "ChristKidz.com Contact Form " . $contactsubject; $Body =""; $Body .="Name: "; $Body .=$Name; $Body .="\n"; $Body .="Phone: "; $Body .=$HomeTel; $Body .="\n"; $Body .="Email: "; $Body .=$Email; $Body .="\n"; $Body .="\n"; $Body .="Message: "; $Body .="\n"; $Body .=$Message; $Body .="\n"; $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>", $ReplyTo); if ($success) { echo "The Following Message has succesfully been sent to the childrens ministry:<br><br>"; echo "Name: $Name<br>"; echo "Phone: $HomeTel<br>"; echo "Email: $Email<br><br>"; echo "Subject: $Subject<br><br>"; echo "Message: $Message<br><br>"; echo "Thank you for your questions or comments, we will reply to them as soon as possible. Have a great day"; } else { echo "Error: Please press back on your browser and try again."; } ?>
  2. I am running Mambo 4.6.1 and have installed the extCalendar component with the latest events module and when the latest events mod runs it produces the following errors: Warning: Invalid argument supplied for foreach() in /home/oviedocc/public_html/modules/mod_extcalendar_latest.php on line 123 Warning: Invalid argument supplied for foreach() in /home/oviedocc/public_html/modules/mod_extcalendar_latest.php on line 171 Warning: Invalid argument supplied for foreach() in /home/oviedocc/public_html/modules/mod_extcalendar_latest.php on line 239 Anybody have any ideas why it might be doing this? Thanks.
  3. ok, so I have a form that is submitted to the DB containing client info and a thumbnail. I also have a program that calls the data from the DB and displays the info in a table. The problem I am having is in displaying the thumbnail. It just displays a lot of code that i guess makes up the image. Anyways, below is my code. Any help would be great. Thanks. the upload form <?php include ("db.inc"); $connection = mysql_connect($host, $user, $password) or die ("Couldn't connect to the server"); $db = mysql_select_db($database, $connection) or die("could not select the DB"); $companyName = Trim(stripslashes($_POST['companyName'])); $companyWeb = Trim(stripslashes($_POST['companyWeb'])); $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } $sql = "INSERT INTO ClientList (companyName, companyWeb, name, size, type, content) VALUES ('$companyName', '$companyWeb', '$fileName', '$fileSize', '$fileType', '$content')"; $result = mysql_query($sql) or die ("Could not execute query"); if($result == "yes") { header("Location: viewclient.php"); echo "Client Successfully Added"; exit; } ?> the view the data code <?php include("db.inc"); $connection = mysql_connect($host, $user, $password) or die ("Could not connect"); $db = mysql_select_db($database, $connection) or die ("Could not connect to DB"); if ($_POST['delete']){ $deleteID = $_POST['delete']; mysql_query("DELETE FROM ClientList WHERE companyName = '$deleteID'") or die (mysql_error()); echo "Successfully Deleted Client<p>"; } $sql = "SELECT * FROM ClientList ORDER BY companyName"; $result = mysql_query($sql) or die("Could not execute query"); echo "<table cellpadding='0' border='1' cellspacing='0' width='500' align='center'>"; echo "<tr><td><font size='-2'>Press Below Button to Delete</font></td><td>Company Name</td>"; echo "<td>Company Web Site</td><td>Thumbnail</td></tr>"; while ($row = mysql_fetch_array($result)) { extract($row); echo "<tr><td align='center'><form id='form1' name='form1' method='post' action='{$_SERVER['PHP_SELF']}'><input type='submit' name='delete' value='{$row['companyName']}' /></form><td>"; echo $companyName."</td>"; echo "<td><a href='http://".$companyWeb."' target='_blank'>".$companyWeb."</a></td>"; echo $content; echo "</tr>"; } echo "</table>"; ?>
  4. Ok, I have a pretty simple table to view my DB items through the website...what I want to be able to do is push the submit button and have it delete the row that coincides with the button....is this possible? Below is my code...I have left the action for the submit button form as XXX b/c I don't know what to put there. Thanks for your help. <?php include("db.inc"); $connection = mysql_connect($host, $user, $password) or die ("Could not connect"); $db = mysql_select_db($database, $connection) or die ("Could not connect to DB"); $sql = "SELECT * FROM ClientList ORDER BY companyName"; $result = mysql_query($sql) or die("Could not execute query"); echo "<table cellpadding='0' border='1' cellspacing='0' width='500' align='center'>"; echo "<tr><td></td><td>Company Name</td>"; echo "<td>Company Web Site</td></tr>"; while ($row = mysql_fetch_array($result)) { extract($row); echo "<tr><td><form id='form1' name='form1' method='post' action='XXXX'><input type='submit' name='Submit' value='Submit' /></form><td>"; echo $companyName."</td>"; echo "<td><a href='http://".$companyWeb."' target='_blank'>".$companyWeb."</a></td>"; echo "</tr>"; } echo "</table>"; ?>
  5. Is there any kind of code/function that will send a table from my db to the printer?
  6. I found out the problem...when I changed the form action to call the same page...I forgot to change it on the .inc file...Your code def. did the trick though...Thanks a lot...
  7. ok, here is my updated code, but still nothing is happening...no errors, no post to the db...it just refreshes the page basically. [code] <?php include('incl_db.php'); include('function.inc'); if ($_POST['Submit']) { $connection = mysql_connect($host, $user, $password) or die ("Couldn't connect to the server."); // Connect $db = mysql_select_db($database, $connection) or die ("Couldn't select database."); $table_id = Trim(stripslashes($_POST['table_id'])); //Set variables $company = Trim(stripslashes($_POST['company'])); $amt_tix = Trim(stripslashes($_POST['amt_tickets'])); $comments = Trim(stripslashes($_POST['comments'])); $sql = "SELECT * FROM `Table` WHERE `table_id`='".$table_id."'"; // SQL statement - select all from table where the table id matchs the inputted one $result = mysql_query($sql) or die("could not execute! ".mysql_error()); $num = mysql_num_rows($result); // If any matches... if($num > 0) { print "That table has already been reserved.)"; // tell the user that is has been taken include ("reservetable_form.inc"); //show form exit; // exit script } else { $sql2 = "INSERT INTO `Table` ( `table_id` ,`company` , `table_amt` , `comments` ) VALUES ('".$table_id."' , '".$company."', '".$amt_tix."', '".$comments."')"; //SQL statement for inserting into the DB $result2 = mysql_query($sql2)  or die("Couldn't execute query. ".mysql_error()); header("Location: index.php"); // Go back to index } } else { include('reservetable_form.inc');//show form if it has not been submitted } ?> [/code]
  8. Ok, I have a form that I am having submitted to the db.  The only catch is that I need it to validate the field table_id does not have the same value twice.  I am using it as sort of a table reservation form where there are 50 tables to choose from, and each table can only be used once.  Here is my below code.  Right now, it is running the program and not doing anything...not posting to the db and not creating any errors...it just brings the form back up.  Here is a link to see it actually working (or not working): http://www.giftfromgodcomputerfoundation.org/staff/reservetable.php [code] <?php include('incl_db.php'); include('function.inc'); $connection = mysql_connect($host, $user, $password) or die ("Couldn't connect to the server."); $db = mysql_select_db($database, $connection) or die ("Couldn't select database."); ?> <?php   include("reservetable_form.inc");     if ($_POST['Submit']) { include("incl_db.php"); $connection = mysql_connect($host, $user, $password) or die ("Couldn't connect to the server."); $db = mysql_select_db($database, $connection) or die ("Couldn't select database."); $table_id = Trim(stripslashes($_POST['table_id'])); $company = Trim(stripslashes($_POST['company'])); $amt_tix = Trim(stripslashes($_POST['amt_tickets'])); $comments = Trim(stripslashes($_POST['comments'])); $sql = "SELECT table_id FROM `Table`"; $result = mysql_query($sql) or die("could not execute1"); $num = mysql_numrows($result); if ($num > 0) { print "That table has already been reserved.)"; include ("reservetable_form.inc"); exit; } else { $sql2 = "INSERT INTO `Table` ( `table_id` ,`company` , `table_amt` , `comments` ) VALUES ('$table_id' , '$company', '$amt_tix', '$comments')"; $result2 = mysql_query($sql2)  or die("Couldn't execute query."); header("Location: index.php"); } //} } ?> [/code] here is the form: [code] <form action="reservetable_action.php" method="POST"> <table border="0"> <tr>   <td align="right"><b>Corporation</b></td>   <td><input name="company" type="text" id="company" size="30" maxsize="50" /></td></tr> <tr>   <td width="120" align="right"><b>Amount of Tickets </b></td>   <td><select name="amt_tickets" id="amt_tickets">         <option value="2">2</option>         <option value="4">4</option>         <option value="6">6</option>       </select></td> </tr> <tr>   <td align="right">Table Required </td>   <td><select name="table_id">   <?php   $tableName=getTableName(); $tableCode=getTableCode(); for ($n=1; $n<=54; $n++) { $table=$tableName[$n]; $tcode=$tableCode[$n]; echo "<option value='$tcode'"; if ($scode== "A1") echo " selected"; echo ">$table\n"; } ?></select> <?php echo $new_message; ?>     </td> </tr> <tr>   <td align="right"><strong>Comments</strong></td>   <td rowspan="4" valign="top"><label>     <textarea name="comments" cols="30" rows="6" id="comments"></textarea>   </label></td>   </tr> <tr>   <td align="right">&nbsp;</td>   </tr> <tr>   <td align="right">&nbsp;</td>   </tr> <tr>   <td align="right">&nbsp;</td>   </tr> <tr><td align="center" colspan="2"><br /><input name="Submit" type="submit" id="Submit" value="Submit" /> </td></tr> </table> </form> [/code]
  9. yes... [code] <form action="reservetable_action.php" method="POST"> <table border="0"> <tr>   <td align="right"><b>Corporation</b></td>   <td><input name="company" type="text" id="company" size="30" maxsize="50" /></td></tr> <tr>   <td width="120" align="right"><b>Amount of Tickets </b></td>   <td><select name="amt_tickets" id="amt_tickets">         <option value="2">2</option>         <option value="4">4</option>         <option value="6">6</option>       </select></td> </tr> <tr>   <td align="right">Table Required </td>   <td><select name="table_id">   <?php   $tableName=getTableName(); $tableCode=getTableCode(); for ($n=1; $n<=54; $n++) { $table=$tableName[$n]; $tcode=$tableCode[$n]; echo "<option value='$tcode'"; if ($scode== "A1") echo " selected"; echo ">$table\n"; } ?></select> <?php echo $new_message; ?>     </td> </tr> <tr>   <td align="right"><strong>Comments</strong></td>   <td rowspan="4" valign="top"><label>     <textarea name="comments" cols="30" rows="6" id="comments"></textarea>   </label></td>   </tr> <tr>   <td align="right">&nbsp;</td>   </tr> <tr>   <td align="right">&nbsp;</td>   </tr> <tr>   <td align="right">&nbsp;</td>   </tr> <tr><td align="center" colspan="2"><br /><input name="Submit" type="submit" id="Submit" value="Submit" /> </td></tr> </table> </form> [/code] Sorry about the indention...I am usually pretty good about it.
  10. i did that (updated code below) and it just produced a blank page. [code] <?php ob_start(); ?> <?php if ($_POST['submit']) { include("incl_db.php"); $connection = mysql_connect($host, $user, $password) or die ("Couldn't connect to the server."); $db = mysql_select_db($database, $connection) or die ("Couldn't select database."); $table_id = Trim(stripslashes($_POST['table_id'])); $company = Trim(stripslashes($_POST['company'])); $amt_tix = Trim(stripslashes($_POST['amt_tickets'])); $comments = Trim(stripslashes($_POST['comments'])); $sql = "SELECT $table_id FROM `Table`"; $result = mysql_query($sql) or die("could not execute"); $num = mysql_numrows($result); if ($num > 0) { $new_message = "That table is already reserved"; //header("Location: reservetable.php"); include("reservetable.php"); exit; } else { $sql2 = "INSERT INTO `Table` ( `table_id` ,`company` , `table_amt` , `comments` ) VALUES ('$table_id' , '$company', '$amt_tix', '$comments')"; $result2 = mysql_query($sql2) or die("Couldn't execute query."); if ($result2 == "yes") { header("Location: index.php"); exit; } } } ?> [/code]
  11. putting the $ in front of table_id errors the sql command and causes it not to execute...
  12. Ok, I have made the changes...but it does not seem like the program is running.  It just puts the message that the table already exists, even when it doesn't exist yet... here is my updated code [code] <?php ob_start(); ?> <?php include("incl_db.php"); $connection = mysql_connect($host, $user, $password) or die ("Couldn't connect to the server."); $db = mysql_select_db($database, $connection) or die ("Couldn't select database."); $table_id = Trim(stripslashes($_POST['table_id'])); $company = Trim(stripslashes($_POST['company'])); $amt_tix = Trim(stripslashes($_POST['amt_tickets'])); $comments = Trim(stripslashes($_POST['comments'])); $sql = "SELECT table_id FROM `Table`"; $result = mysql_query($sql) or die("could not execute"); $num = mysql_numrows($result); if ($num > 0) { $new_message = "That table is already reserved"; //header("Location: reservetable.php"); include("reservetable.php"); exit; } else { $sql2 = "INSERT INTO `Table` ( `table_id` ,`company` , `table_amt` , `comments` ) VALUES ('$table_id' , '$company', '$amt_tix', '$comments')"; $result2 = mysql_query($sql2) or die("Couldn't execute query."); if ($result2 == "yes") { header("Location: index.php"); exit; } } ?> [/code]
  13. I need to check to see if the value for table_id already exists in the db.  If it does, a message needs to post and allow the user to choose a dif table id. Here is what i have...i get the die message of could not execute query for $sql. Any help? [code] <?php include("incl_db.php"); $connection = mysql_connect($host, $user, $password) or die ("Couldn't connect to the server."); $db = mysql_select_db($database, $connection) or die ("Couldn't select database."); $table_id = Trim(stripslashes($_POST['table_id'])); $company = Trim(stripslashes($_POST['company'])); $amt_tix = Trim(stripslashes($_POST['amt_tickets'])); $comments = Trim(stripslashes($_POST['comments'])); $sql = "SELECT table_id FROM Table"; $result = mysql_query($sql) or die("could not execute"); $num = mysql_numrows($result); if ($num > 0) { echo "That table is already reserved"; header("Location: reservetable.php"); } else { $sql2 = "INSERT INTO `Table` ( `table_id` ,`company` , `table_amt` , `comments` ) VALUES ('$table_id' , '$company', '$amt_tix', '$comments')"; $result2 = mysql_query($sql2) or die("Couldn't execute query."); if ($result2 == "yes") { header("Location: index.php"); exit; } } ?> [/code]
  14. I am trying to come up with a program that list available seating options for the amount of people that they choose...I am not going to get too crazy...I am only giving them the option of a two seater, 4, and six seater. I have a mysql db setup with a list of tables and the amount each table holds. I want my user to be able to select from the amount of tickets list (2,4, or 6) and have then have the next list which is calling all the the tables from the db to automatically update with the tables that will hold that amount. Here is what I have so far.... [code] <form action="reservetable_action.php" method="POST"> <table border="0"> <tr>   <td align="right"><b>Corporation</b></td>   <td><input name="company" type="text" id="company" size="30" maxsize="50" /> </td></tr> <tr>   <td width="120" align="right"><b>Amount of Tickets </b></td>   <td><label>     <select name="amt_tickets" id="amt_tickets">       <option value="2">2</option>       <option value="4">4</option>       <option value="6">6</option>         </select>   </label></td> </tr> <tr>   <td align="right"><strong>Select Table </strong></td>   <td> <?php echo "<label>"; echo "<select name='list_table' id='list_table'>"; while ($row = mysql_fetch_array($result)) { extract($row); echo "<option value='".$table_id."'>"; echo $table_id; echo "</option>"; } echo "</select>"; echo "</label>"; ?></td> </tr> <tr>   <td align="right" valign="top">&nbsp;</td>   <td valign="top"><p>&nbsp;</p>     </td> </tr> <tr>   <td align="right"><strong>Comments</strong></td>   <td rowspan="4" valign="top"><label>     <textarea name="comments" cols="30" rows="6" id="comments"></textarea>   </label></td>   </tr> <tr>   <td align="right">&nbsp;</td>   </tr> <tr>   <td align="right">&nbsp;</td>   </tr> <tr>   <td align="right">&nbsp;</td>   </tr> <tr><td align="center" colspan="2"><br /><input name="Submit" type="submit" id="Submit" value="Submit" /> </td></tr> </table> </form> [/code] Right now, this lists all tables regardeless of what was input into the amount of tix list.  Any ideas?  Thanks.
  15. I also realized that it should have been... header("Location: url"); instead of header('url'); Thanks for you help.
  16. Here is the code for my logout link: [code] <a href="logout.php">Logout</a> [/code] Here is logout.php: [code] <?php header('http://www.giftfromgodcomputerfoundation.org'); session_destroy();   ?> [/code] What i need it to do is logout the user and return them to the main page.... I get the following error: Warning: session_destroy() [function.session-destroy]: Trying to destroy uninitialized session in /home/giftfrom/public_html/staff/logout.php on line 5
  17. I am wanting a timestamp to be placed into my db when the form is submitted, below is my php code for trying to do this: [code] $timestamp = date('Y d m h:i:s'); echo $timestamp; $sql  = "insert into upload SET id='$id' , business='$business', address='$address', city='$city', contact='$contact', salesrep='$salesrep', phone='$phone', email='$email', name='$fileName', time='$timestamp' "; [/code]
  18. I have a script that checks file size to make sure each file is under 50kb when they upload. the way my form is, it puts the file size into an array...me being dumb and having no idea how to pull it out of an array used implode() however, that just adds the 2 numbers next to each other eg. 1 file is 50 bytes the other 100...the output of implode()50100. Is there a function that will actually take the numbers individually through my check file_size code as below: [code] $max_size = "500000"; // 50000 is the same as 50kb $print_size = ($max_size/1000)."kb"; // Check File Size $file_size = $_FILES['file']['size']; if ($ok == "1") { if(implode($file_size) > $max_size) { print "<font color='#FF0000'>Error:</font> One of your files is too large.  It must be ".$print_size." or less."; print "<br><br><a href='procedures.html'>back</a>"; exit; } [/code]
  19. Ok, I had the below code to check file extensions.  I have changed my upload code to handle more than 1 upload at a time, however in doing that, the pathinfo() is no longer reading 1 file name, it is reading an array and thus causing errror. Here is my original code for checking extensions: [code] $allowed_ext = "jpg, gif, png, pdf, txt, psd, ai, doc, zip, rar, gz, jpeg"; // These are the allowed extensions of the files that are uploaded // Check Entension $extension = pathinfo($_FILES['file']['name']); $extension = $extension[extension]; $allowed_paths = explode(", ", $allowed_ext); for($i = 0; $i < count($allowed_paths); $i++) { if ($allowed_paths[$i] == "$extension") { $ok = "1"; } } [/code]
  20. I have the below code that will allow me to upload 1 file.  Is there a way to loop it, so I can have multiple file uploads? [code] $dir = "artwork/".$business; $rights = 0777; if (is_dir("$dir")) { echo "A directory with your busines name ".$business." already exists and your files have been uploaded to that directory.  If this has been done in error, please contact the website administrator.  Thank you.<br><br>"; } else { mkdir ($dir, $rights); echo "A directory named ".$business." has just been created.  Thank you.<br><br>"; } $allowed_ext = "jpg, gif, png, pdf, txt, psd, ai, doc, zip, rar, gz, jpeg"; // These are the allowed extensions of the files that are uploaded $max_size = "50000"; // 50000 is the same as 50kb $print_size = ($max_size/1000)."kb"; //$max_height = "100"; // This is in pixels - Leave this field empty if you don't want to upload images //$max_width = "100"; // This is in pixels - Leave this field empty if you don't want to upload images // Check Entension $extension = pathinfo($_FILES['file']['name']); $extension = $extension[extension]; $allowed_paths = explode(", ", $allowed_ext); for($i = 0; $i < count($allowed_paths); $i++) { if ($allowed_paths[$i] == "$extension") { $ok = "1"; } } // Check File Size if ($ok == "1") { if($_FILES['file']['size'] > $max_size) { print "<font color='#FF0000'>Error:</font> File size is too large.  It must be ".$print_size; print "<br><br><a href='procedures.html'>back</a>"; exit; } // Check Height & Width //if ($max_width && $max_height) { //list($width, $height, $type, $w) = getimagesize($_FILES['file']['tmp_name']); //if($width > $max_width || $height > $max_height) //{ //print "File height and/or width are too big!"; //exit; //} //} //check if the file exists if(file_exists($dir.'/'.$_FILES['file']['name'])){     print "<font color='#FF0000'>Error:</font> File: (".$_FILES['file']['name'].") already exists.<br><br>"; print "<a href='procedures.html'>back</a>"; exit; } // The Upload Part if(is_uploaded_file($_FILES['file']['tmp_name'])) { move_uploaded_file($_FILES['file']['tmp_name'],$dir.'/'.$_FILES['file']['name']); } print "Your file has been uploaded successfully. Thank you.<br><br>"; print "<a href='procedures.html'>back</a>"; } else { print "<font color='#FF0000'>Error:</font> Incorrect file extension. File must be one of the following:<br>".$allowed_ext; print "<br><br><a href='procedures.html'>back</a>"; } [/code]
  21. I have the following line mkdir ($dir, 0777); which should make a directory based on $dir and then give that directory all permissions...this is not happening....it is giving the following permissions (sorry for the way I am writing it, but I am not that savy with permissions) drwxr-xr-x....is the line of code not correct or is it something someplace else.... 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.