Jump to content

adding the email section to my view listings page


Cflax

Recommended Posts

hope someone can help me out here, stuck on this page...

This page shows the details of the listing they had just clicked on on the previous page. this part works

If the person logged in is the person who is looking at the page, the email section does not show. this part works

However, the part I cannot get to work, is when the logged in user types their email message and clicks send email. at this point the details of listing stop showing

PLZ SOMEONE HELP ME

thanks in advance, i hope

<?php
  // Start the session
  require_once('startsession.php');

  // Insert the page header
  $page_title = 'Listing Details';
  require_once('header.php');

  require_once('connectvars.php');

  // Show the navigation menu
  require_once('navmenu.php');


if(isset($_POST['submit'])){
 $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); 

  // Retrieve the user data from MySQL
  $query1 = 'SELECT email FROM ob_user WHERE username="' . $user_name . '"';
  $data1 = mysqli_query($dbc, $query1);
  $row1 = mysqli_fetch_array($data1);
  
  $email = $row1['email'];
  
$to = $email;
$subject = 'OurBazzar response to' . $subject . '';
$body = $_POST['email'];
$headers = 'From: caleb.jordan.flax@gmail.com';
if (mail($to, $subject, $body, $headers)) {
   echo("<p>Message sent!</p>");
  } else {
   echo("<p>Message delivery failed...</p>");
  }
  end();
}



  if (isset($_GET['listing_id']) && isset($_GET['subject']) && isset($_GET['description']) && isset($_GET['price']) && isset($_GET['date']) && isset($_GET['city']) && isset($_GET['state']) && isset($_GET['user_id']) && isset($_GET['category_id'])) {
  
    // Grab the score data from the GET
    $listing_id = $_GET['listing_id'];
    $title = $_GET['subject'];
    $description = $_GET['description'];
    $price = $_GET['price'];
    $date = $_GET['date'];
$city = $_GET['city'];
    $state = $_GET['state'];
    $userid = $_GET['user_id'];
    $categoryid = $_GET['category_id'];

  }

// Connect to the database 
  $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); 

  // Retrieve the user data from MySQL
  $query = 'SELECT username FROM ob_user WHERE user_id="' . $userid . '"';
  $data = mysqli_query($dbc, $query);
  $row = mysqli_fetch_array($data);

  $query1 = 'SELECT name FROM ob_category WHERE category_id="' . $categoryid . '"';
  $data1 = mysqli_query($dbc, $query1);
  $row1 = mysqli_fetch_array($data1); 
  
$user_name = $row['username'];
$category_name = $row1['name']; 	

echo '<table>';
echo '<tr><td colspan="2"><strong>' . $title . '</strong></td></tr>';
echo '<tr><td>Created by: </td><td>' . $user_name . '</td></tr>';
echo '<tr><td>Date created: </td><td>' . $date . '</td></tr>';
echo '<tr><td>Location: </td><td>' . $city . ', ' . $state . '</td></tr>';
echo '<tr><td>Category: </td><td>' . $category_name . '</td></tr>';
echo '<tr><td>Description: </td><td>' . $description . '</td></tr>';
echo '</table>'; 

if ((isset($_SESSION['username'])) && ($_SESSION['username'] != $user_name)) {

?>

<br />
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<fieldset>
<legend>Send Email to <?php echo $user_name; ?></legend>
<label for="email">Message: </label>
<input type="text" name="email" /><br />
<input type="submit" value="Send Email" name="submit">
</fieldset>

<?php

}
require_once('footer.php');
?>

Link to comment
Share on other sites

Seems like a lot of info being passed by GET.  I would just pass an ID with GET and grab the info on this page.  Pass the id as a hidden value in the form, to a processing page and after values are stored or used to send email take them back to the page they were on with a header location line.  For example: header("Location:mypage.php?listing_id=$id");  Just a suggestion.

 

I would think you'd want to do some email validation so you might look into that.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.