Jump to content

echocpt

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

echocpt's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, im trying to create a emailing script where a user can choose peoples emails by a group name. At the moment im stuck as the code im running just stops at a blank page. Iv even tryed adding error_reporting(E_ALL); ini_set('display_errors', '1'); error code to the page, but it still turns blank and does not send the email, could anyone look at the code and help out maybe? Thanks. HTML Code. <?php $query = "SELECT DISTINCT `email`, `group` FROM `email`"; $result = mysql_query($query) or die(); ?> <?php if ($_GET['email']==true) { ?> <div class="msg_body"> <p class="msg_head2">Email Users></p> <form id="form5" name="form5" method="post" action="email.php"> <table width="638" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="190" height="28" valign="top"><p><strong>Add User:</strong></p> </td> <td width="449"><label></label></td> </tr> <tr> <td height="30">To:</td> <td><label> <select name="emailgroup"> <?php while($row = mysql_fetch_assoc($result)) { echo "<option value=''" . $row['email'] . "'>" . $row['group'] . "</option>"; } ?> </select> </label></td> </tr> <tr> <td height="30">Subject:</td> <td><label> <input name="subject" type="text" class="area" id="subject" /> </label></td> </tr> <tr> <td height="30">Content:</td> <td><label> <textarea name="emailcontent" id="emailcontent" class="box" cols="50" rows="8"></textarea> </label></td> </tr> <tr> <td height="30"> </td> <td><label></label> <label></label></td> </tr> <tr> <td height="30"> </td> <td><label></label></td> </tr> <tr> <td> </td> <td><input type="submit" name="submit" id="submit" value="Send Email" /></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> </table> </form> <br /> <br /> <br /> </div> <?php } ?> php code: <?php include("connection.php"); if(isset($_POST['submit'])) { $group = $_POST['emailgroup']; $query = "SELECT 'email' FROM `email` WHERE group=\"" . $group . "\""; $result = mysql_query($query) or die(); $row = mysql_fetch_object($result); $emailusers = array (email); $Name = "Woodbridge School CCF"; //senders name $email = "delt_cpt@hotmail.com"; //senders e-mail adress $message = $_POST['emailcontent'] ; $subject = $_POST['subject'] ; mail($emailusers, $subject, $message, "From: $email"); echo "Email Sent"; } else { header('admin.php?email=true'); } ?>
  2. Hi, thanks i looked into that and have changed, unfortunatly still no luck. Im thinking that maybe it could be something to do with pulling the email addresses from the table in the DB and then adding them. If so i would have thort it would be to do with these lines? echo "<option value=''" . $row['email'] . "'>" . $row['group'] . "</option>"; in the html form $emailusers = $_POST['emailusers']; and mail($emailusers, $subject, $message, "From: $email"); in the php code. Thanks
  3. Hi, once again i find myself needing some help from this fantastic site. I am trying to code an email script where the admin of my site can send emails to a group of users through the use of a form. At the moment, the admin can select a group to email through the use of a select box linked to a mysql database. He also adds the subject and message in the form and then clicks the submit button. This is where im confused. The email send script tells me the email has been sent when really nothing is being sent. Could any1 help me sort this 'small' problem . Thanks. html email form: <?php $query = "SELECT `email`, `group` FROM `email`"; ?> <?php if ($_GET['email']==true) { ?> <div class="msg_body"> <p class="msg_head2">Email Users></p> <form id="form5" name="form5" method="post" action="email.php"> <table width="638" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="190" height="28" valign="top"><p><strong>Add User:</strong></p> </td> <td width="449"><label></label></td> </tr> <tr> <td height="30">To:</td> <td><label> <select name="emailusers"> <?php $result = mysql_query($query) or die(); while($row = mysql_fetch_assoc($result)) { echo "<option value=''" . $row['email'] . "'>" . $row['group'] . "</option>"; } ?> </select> </label></td> </tr> <tr> <td height="30">Subject:</td> <td><label> <input name="subject" type="text" class="area" id="subject" /> </label></td> </tr> <tr> <td height="30">Content:</td> <td><label> <textarea name="emailcontent" id="emailcontent" class="box" cols="50" rows="8"></textarea> </label></td> </tr> <tr> <td height="30"> </td> <td><label></label> <label></label></td> </tr> <tr> <td height="30"> </td> <td><label></label></td> </tr> <tr> <td> </td> <td><input type="submit" name="submit" id="submit" value="Send Email" /></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> </table> </form> <br /> <br /> <br /> </div> <?php } ?> The php email form: <?php include("connection.php"); if(isset($_POST['submit'])) { $Name = "Woodbridge School CCF"; //senders name $email = "delt_cpt@hotmail.com"; //senders e-mail adress $message = $_POST['emailcontent'] ; $subject = $_POST['subject'] ; $emailusers = $_POST['emailusers']; mail($emailusers, $subject, $message, $email); //mail command echo "Email Sent"; } else { header('admin.php?email=true'); } ?> Thanks.
  4. Hi, thanks for that, i changed the code as advised, however it still doesn't work. I am wondering (as i have used this same idea in a pervious site with sucsess) if it is something to do with the line echo "<option value='http://www.zerodefex.net/ccf/redo/pages/admin.php?user=true?UserID=" . $row['id'] . "'>" . $row['username'] . "</option>"; and in particular the /admin.php?user=true?UserID=" bit as iv never used the double "?" before. I persoanlly can't see anything else wronge with the select area, but if its not what i just stated, i assume its to do with the actuall form area with the textboxes? Any help? Thanks.
  5. Hi, can anyone surgest a reason why this piece of script aint working. It should be filling the text boxes but wont. The select feature seems to be working fine and redirects the url fine, but the boxes wont fill with info. Thanks. <?php $query = "SELECT id, username FROM user"; $result = mysql_query($query) or die(); ?> <form> Select user to edit: <select name="menu"> <?php while($row = mysql_fetch_assoc($result)) { echo "<option value='http://www.zerodefex.net/ccf/redo/pages/admin.php?user=true?UserID=" . $row['id'] . "'>" . $row['username'] . "</option>"; } ?> </select> <input type="button" onClick="location=this.form.menu.options [this.form.menu.selectedIndex].value;" value="Edit User"> </form> <?php include('connection.php'); $query = "SELECT id, username, password, permission, pin, email FROM user WHERE id = '" . $_GET['UserID'] . "'"; $result = mysql_query($query) or die(); $row = mysql_fetch_object($result); ?> <form id="form7" name="form7" method="post" action="update.php"> <table width="638" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="190" height="28" valign="top"><p><strong>Edit User:</strong></p> </td> <td width="449"><label></label></td> </tr> <tr> <td height="30">Username:</td> <td><input name="username2" type="text" class="area" id="username2" value="<?php echo $row->username; ?>" /></td> </tr> <tr> <td height="30">Password:</td> <td><label> <input name="password3" type="text" class="area" id="password3" value="<?php echo $row->password; ?>" /> </label></td> </tr> <tr> <td height="30">Email:</td> <td><label> <input name="email2" type="text" class="area" id="email2" value="<?php echo $row->email; ?>" /> </label></td> </tr> <tr> <td height="30">Pin:</td> <td><label> <input name="pin5" type="text" class="area" id="pin5" value="<?php echo $row->pin; ?>" /> </label></td> </tr> <tr> <td height="30"> </td> <td><label> <input name="userid" type="hidden" value="<?php echo $_GET['UserID']; ?>" /> <input type="submit" name="submit3" id="submit3" value="Edit User" /> </label></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> </table> </form> <br /> <br /> </div> <?php } ?>
  6. Hi i have got this php script that inserts info added from a user into a database and it all work excepet for the date. I was wondering if anyone could help me get it working? The date should upload to the DB in a yyyy-mm-dd format and then redisplay itself but atm wont add. The "article.php" code: <?php // Include the database connection file. include("connection.php"); // Check if a person has clicked on submit. if(isset($_POST['submit'])) { // Check if a person has filled every form. if(empty($_POST['title']) || empty($_POST['content']) || empty($_POST['page'])) { header("Location: admin.php?h=true"); // Redirect to the form. exit; // Stop the code to prevent the code running after redirecting. } // Create variables from each $_POST. $title = $_POST['title']; $content = $_POST['content']; $page = $_POST['page']; $day = $_POST['day1']; $month = $_POST['month1']; $year = $_POST['year1']; $full = $year . $month . $day; } // Create a variable containing the SQL query. $query = "INSERT INTO 'content' (title, content, page, date) VALUES ('$title', '$content', '$page', '$full')"; // Perform the SQL query on the database. $result = mysql_query($query); // If the query failed, display an error. if(!$result) { echo "Your query failed. " . mysql_error(); // The dot seperates PHP code and plain text. } else { // Display a success message! header("Location: admin.php?d=true"); } ?> This is the HTML from code: <form id="form1" name="form1" method="post" action="article.php"> <table width="638" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="190" height="28" valign="top"> <strong>Add a new article:</strong></td> <td width="448"><label></label></td> </tr> <tr> <td height="28">Title:</td> <td> <input name="title" type="text" class="area" id="title" /></td> </tr> <tr> <td height="33">Date:<br /> (day/month/year) format</td> <td><label> <select name="day1" size="" id="day1"> <option>01</option> <option>02</option> <option>03</option> <option>04</option> <option>05</option> <option>06</option> <option>07</option> <option>08</option> <option>09</option> <option>10</option> <option>11</option> <option>12</option> <option>13</option> <option>14</option> <option>15</option> <option>16</option> <option>17</option> <option>18</option> <option>19</option> <option>20</option> <option>21</option> <option>22</option> <option>23</option> <option>24</option> <option>25</option> <option>26</option> <option>27</option> <option>28</option> <option>29</option> <option>30</option> <option>31</option> </select> <select name="month1" id="month1"> <option>01</option> <option>02</option> <option>03</option> <option>04</option> <option>05</option> <option>06</option> <option>07</option> <option>08</option> <option>09</option> <option>10</option> <option>11</option> <option>12</option> </select> <select name="year1" id="year1"> <option>2008</option> <option>2009</option> <option>2010</option> <option>2011</option> <option>2012</option> <option>2013</option> <option>2014</option> <option>2015</option> <option>2016</option> <option>2017</option> <option>2018</option> <option>2019</option> <option>2020</option> <option>2021</option> <option>2022</option> <option>2023</option> <option>2024</option> <option>2025</option> </select> </label></td> </tr> <tr> <td height="141">Content:</td> <td><label></label><label> <textarea name="content" cols="50" rows="8" class="box" id="content"></textarea> </label></td> </tr> <tr> <td height="33">Add to:</td> <input name="groupid" type="hidden" value="<?php echo $_GET['id']; ?>" /> <td><select name="page" id="page"> <option>Home</option> <option>News</option> </select></td> </tr> <tr> <td height="34"> </td> <td><label> <input type="submit" name="button" id="button" value=" Post " /></form>
  7. Hi, i thort i had solved the problem and so "Solved" the last topic. Unfortunatly the file is playing up again. Ok, i have a login script that compromises 2 pages. The first page has the form that users fill in their username and password in and click submit (admin.php) and the second page is php code to check the login details, (loging2.php). I currently have a problem with them. When the submit button is clicked the login2.php page will work its magic, but for some reason stops half way through and redirects me to the form to try again. As far as i can see there is no problem and no error gets displayed, can anyone help? I think its arround line 39 were its wronge but dont know. The login2.php file: <?php // login2.php // Start a session. Session is explained below. session_start(); include("connection.php"); // Same checking stuff all over again. if(isset($_POST['submit'])) { if(empty($_POST['username']) || empty($_POST['password'])) { header("Location: admin.php?login=true"); exit; } // Create the variables again. $username = $_POST['username']; $password = $_POST['password']; // Encrypt the password again with the md5 hash. // This way the password is now the same as the password inside the database. $password = md5($password); // Store the SQL query inside a variable. // ONLY the username you have filled in is retrieved from the database. $query = "SELECT username,password FROM `user` WHERE username='$username'"; $result = mysql_query($query); if(!$result) { // Gives an error if the username given does not exist. // or if something else is wrong. echo "The query failed " . mysql_error(); } else { // Now create an object from the data you've retrieved. $row = mysql_fetch_object($result); // You've now created an object containing the data. // You can call data by using -> after $row. // For example now the password is checked if they're equal. if($row->password != $password) { header("Location: admin.php?login=true"); exit; } // By storing data inside the $_SESSION superglobal, // you stay logged in until you close your browser. $_SESSION['username'] = $username; $_SESSION['sid'] = session_id(); // Make it more secure by storing the user's IP address. $_SESSION['ip'] = $_SERVER['REMOTE_ADDR']; // Now give the success message. // $_SESSION['username'] should print out your username. header("Location: welcome.php"); } } ?> The "admin.php" file (the form bit): <form id="form6" name="form6" method="post" action="login2.php"> <table width="638" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="190">Username:</td> <td width="449"><label> <input name="username" type="text" class="area" id="username" value="" /> </label></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td>Password:</td> <td><label> <input name="password" type="password" class="area" id="password" value="" /> </label></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td><label> <input type="submit" name="submit" id="submit" value="Login" /></form> .....not all the code, just what is needed for this problem. I have also tried replacing the area were i think it goes wronge (line 39) with this code to try and get an error but nothing is diplayed for the error. if($row->password != $password) { echo "work!" . mysql_error(); exit; } Thanks for anyhelp
  8. Sorry for the double post but it seems u can't edit posts for some crazy reason. Completly forgot to post the error message displayed which was: Warning: Cannot modify header information - headers already sent by (output started at /home/zerosite/public_html/ccf/redo/pages/login2.php:39) in /home/zerosite/public_html/ccf/redo/pages/login2.php on line 49 Thanks
  9. Hi, basicly i have a login script that i have already used for one of my sites and it worked fine but when i moved it over to a new site it is'nt working. Could someone please point me in the correct direction? Thanks alot. This is the login php code for "login2.php": <?php // login2.php session_start(); include("connection.php"); if(isset($_POST['submit'])) { if(empty($_POST['username']) || empty($_POST['password'])) { header("Location: login.php"); exit; } $username = $_POST['username']; $password = $_POST['password']; $password = md5($password); $query = "SELECT username,password FROM `user` WHERE username='$username'"; $result = mysql_query($query); if(!$result) { echo "The query failed " . mysql_error(); } else { $row = mysql_fetch_object($result); if($row->password != $password) { echo "The password is fucked" . mysql_error(); } $_SESSION['username'] = $username; $_SESSION['sid'] = session_id(); $_SESSION['ip'] = $_SERVER['REMOTE_ADDR']; header("Location: welcome.php"); exit; } } ?> This is the html form code: <form id="form6" name="form6" method="post" action="login2.php"> <table width="638" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="190">Username:</td> <td width="449"><label> <input name="username" type="text" class="area" id="username" value="" /> </label></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td>Password:</td> <td><label> <input name="password" type="password" class="area" id="password" value="" /> </label></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td><label> <input type="submit" name="submit" id="submit" value="Login" /></form> Thanks for any help.
  10. lol thanks, its allways the simple things u never spot.
  11. Hi basicly im trying to make a page that will upload an image into a folder, but at the same time add information to a database. The image script works fine on its own, but the second i try incorporating the database bit aswell i get a unexpected T_IF Error. Any help please? Thanks. The php code "upload.php" <?php include("connection.php") if(isset($_POST['submit'])) { if(empty($_POST['title']) || empty($_POST['description']) || empty($_POST['userfile'])) { header("Location: admin.php?m=true"); exit; } $title = $_POST['title']; $description = $_POST['description']; $query = "INSERT INTO `media` (url, title, description) VALUES ('"$upload_path . $filename"', '" . $title . "', '" . $description . "')"; $result = mysql_query($query); if(!$result) { echo "Your query failed. " . mysql_error(); } else { $allowed_filetypes = array('.jpg','.gif','.bmp','.png'); $max_filesize = 2097152; $upload_path = 'images/'; $filename = $_FILES['userfile']['name']; $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); if(!in_array($ext,$allowed_filetypes)) die('The file you attempted to upload is not allowed.'); if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize) die('The file you attempted to upload is too large.'); if(!is_writable($upload_path)) die('You cannot upload to the specified directory, please CHMOD it to 777.'); if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename)) echo 'Your file upload was successful, view the file <a href="' . $upload_path . $filename . '" title="Your File">here</a>'; // It worked. else echo 'There was an error during the file upload. Please try again.'; // It failed . } } ?> The html code. (Not from begining to end) <td height="29">Select Image:<br /> (2 megabytes limit)</td> <td><input type="file" name="userfile" id="file"> </td> </tr> <tr> <td height="30">Add Title:</td> <td><label> <input type="text" name="title" id="title" /> </label></td> </tr> <tr> <td height="141">Add Description: </td> <td><label> <textarea name="description" id="description" class="box" cols="50" rows="8"></textarea> </label></td> </tr> <tr> <td> </td> <td><label></label></td> </tr> <tr> <td> </td> <td><input type="submit" name="submit" id="submit" value="Upload Image" /></td> The ERROR displayed is Parse error: syntax error, unexpected T_IF in /home/zerosite/public_html/ccf/redo/pages/upload.php on line 4 Just incase you want to know aswell the table in the database has 4 fields and they are "id, url, title, description" Thank-You in advance all help appreciated.
×
×
  • 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.