Jump to content

ahaberman25

Members
  • Posts

    28
  • Joined

  • Last visited

ahaberman25's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. You can use implode foreach($update_data as $field=>$data) { $update[] = '`' . $field . '` = \'' . $data . '\''; } mysql_query("UPDATE `admin` SET " . implode(', ', $update) . " WHERE `id` = $session_user_id");
  2. How come this wont work? $check = mysql_query($data); if (mysql_num_rows($check) > 0) { echo 'yes'; $res = mysql_query("SELECT * FROM $tbl_name WHERE id='$id'"); while($row = mysql_fetch_array($res) && $deal = mysql_fetch_array($check)) { echo "<p>You have earned " . $deal['name'] . " worth " . $deal['value'] ." dollars.</p>"; // Send notification email. $to = $row['email']; // this is your Email address $from = "andrew@websbydrew.com"; // this is the sender's Email address // $first_name = $_POST['first_name']; // $last_name = $_POST['last_name']; $subject = "You have earned a free ??? "; $subject2 = "Copy of reward notification"; $message = "You have earned " . $deal['name'] . " worth " . $deal['value'] ." dollars."; $message2 = "customer " . $row['name'] . " has earned a free " . $deal['name']; $headers = "From:" . $from; $headers2 = "From:" . $to; mail($to,$subject,$message,$headers); mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender echo "Notification has been sent to " . $row['email']; // You can also use header('Location: thank_you.php'); to redirect to another page. // You cannot use header and echo together. It's one or the other. } it will only use $deal[]
  3. Figured it out thanks guys $data = "SELECT * FROM deals LEFT JOIN customers ON deals.admin_id = customers.admin_id WHERE deals.visits = customers.visits AND customers.id = $id"; $check = mysql_query($data); if (mysql_num_rows($check) > 0)
  4. I just need to use the query in a if statement to send an email. How do you do that?
  5. Well the check is only when someone is "checked in" so It should only send an email to the one person checking in defined by $id
  6. okay I think this is returning the proper data now. how do i do a if ($data === true){ } do i set the query true false like other queries? mysql_result(mysql_query("SELECT deals.email, deals.visits FROM deals LEFT JOIN customers ON deals.admin_id = customers.admin_id WHERE deals.visits = customers.visits"), 0) == 1) ? true : false;
  7. All I am trying to do is check 2 tables to see if column deals in table customers matches column deals in table deals where admin_id equals the same in both, than send an email if it is equal to each other. I am having issues trying to get this to work.
  8. ive updated it to this, i think its closer but not completely there. $admin_id = $user_data['id']; $data = "SELECT * FROM customer, deals WHERE `admin_id` = $admin_id"; $info = mysql_fetch_array( $data ); while($info = mysql_fetch_array( $data )) { if ($info['customer.visits'] == $info['deals.visits']) { $res = mysql_query("SELECT * FROM $tbl_name WHERE id='$id'"); while($row = mysql_fetch_array($res)) { echo "<p>You have earned " . $row['visits'] . " punch.</p>"; // Send notification email. $to = $row['email']; // this is your Email address $from = "andrew@websbydrew.com"; // this is the sender's Email address // $first_name = $_POST['first_name']; // $last_name = $_POST['last_name']; $subject = "You have earned a free ??? "; $subject2 = "Copy of reward notification"; $message = "You have " . $row['visits'] . " visits left"; $message2 = "id " . $row['id'] . " has " . $row['visits'] . " visits"; $headers = "From:" . $from; $headers2 = "From:" . $to; mail($to,$subject,$message,$headers); mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender echo "Notification has been sent to " . $row['email']; // You can also use header('Location: thank_you.php'); to redirect to another page. // You cannot use header and echo together. It's one or the other. } } } }
  9. checkin.php <?php ob_start(); include 'core/init.php'; protect_page(); // get value of id in URL querystring $id = isset($_GET['id']) ? $_GET['id'] : null; $tbl_name = "customers"; // Table name if (!empty($id)) { // Retrieve user from database $sql = "SELECT * FROM $tbl_name WHERE id='$id'"; $result = mysql_query($sql); $user = mysql_fetch_array($result); if (empty($user)) { // You have no user, do something here to alert the user of this... echo '<h1>Your Membership is no longer active.</h1>' . PHP_EOL; } else { ?> <form name="form1" id="mainForm" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input type="hidden" name="id" value="<?php echo $id; ?>"/> <input type="submit" value="CHECK IN"> </form> <?php } } if (!empty($_POST['id'])) { $id = $_POST['id']; $query = "UPDATE $tbl_name SET `visits` = `visits` + 1 WHERE id = '$id'"; mysql_query($query); $admin_id = $user_data['id']; $check_deal = "SELECT * FROM deals WHERE `admin_id` = $admin_id"; $check_visits = ""; $req_visits = "SELECT * FROM customers WHERE `admin_id` = $admin_id AND `visits` = $check_visits"; if ($visits = $check_visits) { $res = mysql_query("SELECT * FROM $tbl_name WHERE id='$id'"); while($row = mysql_fetch_array($res)) { echo "<p>You have earned " . $row['visits'] . " punch.</p>"; // Send notification email. $to = $row['email']; // this is your Email address $from = "andrew@websbydrew.com"; // this is the sender's Email address // $first_name = $_POST['first_name']; // $last_name = $_POST['last_name']; $subject = "You have earned a free ??? "; $subject2 = "Copy of reward notification"; $message = "You have " . $row['visits'] . " visits left"; $message2 = "id " . $row['id'] . " has " . $row['visits'] . " visits"; $headers = "From:" . $from; $headers2 = "From:" . $to; mail($to,$subject,$message,$headers); mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender echo "Notification has been sent to " . $row['email']; // You can also use header('Location: thank_you.php'); to redirect to another page. // You cannot use header and echo together. It's one or the other. } } } ?> init.php <?php session_start(); //error_reporting(0); require 'database/connect.php'; require 'functions/general.php'; require 'functions/users.php'; if (logged_in() === true) { $session_user_id = $_SESSION['id']; $user_data = user_data($session_user_id, 'id', 'username', 'password', 'fname', 'lname', 'email', 'qr_img'); if (user_active($user_data['username']) === false) { session_destroy(); header('Location: index.php'); exit(); } } $errors = array(); ?>
  10. I have done an entire site out of php with several queries the logic on this is just driving me nuts.
  11. I need to check values from 2 different tables and make sure the admin_id match then do if (value1 = value2) { //do something } this is what I have so far. $admin_id = $user_data['id']; $visits = "SELECT * FROM customers WHERE `admin_id` = $admin_id AND `visits` == $check_visits"; $check_visits = "SELECT * FROM deals WHERE `visits` >= $visits AND `admin_id` = $admin_id"; if ($visits = $check_visits) { send email }
  12. Just launched a new ecom site King Soap. We sell all natural/vegan/goat milk soap on a subscription per month with incentives to invite people to get soap as well. We are in pre-launch and trying to find bugs and curtain things that are just not right on the site whether is formatting or code issues. There is php/jquery/javascript/and html. Let us know what you think. King Soap
  13. One of the issues might be that the code is in the wrong spot, which just putting the relevent code wouldnt do anything in this case. I put in all the information that I had for the issue. I have tried for 2 days going over the code over and over trying to figure out of I left something out or if something is incorrect. The downloads are checked for viruses and what not by the server so that shouldnt be an issue, plus HTML files cant carry anything. This site is full of stuck up people that wont answer a question unless you write a novel on what you did to fix the issue and the code snippet is 3 lines or less. There is 3 different sections of the page where the code is inserted and wouldnt make sense if I only posted a snippet of code. Ill find somwhere else and not help anyone else on here.
  14. I give up I help people when I can but I rarely get an answer on this site.
  15. I am trying to calculate BMI using a sample of code I have used before, It works in the version I previously had but when I try to apply it to some new code that I am making it is no longer working. Is there something im missing? Code is attached before and after before: berlinbmi.html after: berlin test.html Thanks for any help that can be given. berlinbmi.html berlin test.html
×
×
  • 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.