Search the Community
Showing results for tags 'query database'.
-
Hello, I am trying to set up a page where a member who is logged in can access other member's pages, then send an email to the member who has posted a certain page so that the member who is logged in can make comments. At this stage the logged in member doesn't necessarily know the email address of the member who had posted the page that the logged in member has pulled up. I have tried several combinations and I am not getting an error message. The email is not being received at the test email inbox. Any help would be appreciated. Thanks. Following is my current code: $q = "SELECT topics.users_id, users.email FROM topics INNER JOIN users ON topics.users_id = users.id WHERE topics.id=$id" ; $r = mysqli_query ($connect, $q); if (mysqli_num_rows($r) > 0) { while ($row = mysqli_fetch_array($r, MYSQLI_NUM)) { } } echo '<h3>Contact Me</h3>'; // Check for form submission: if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Minimal form validation: if (!empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['comments']) ) { // Create the body: $body = "Name: {$_POST['name']}\n\nComments: {$_POST['comments']}"; // Make it no longer than 100 characters long: $body = wordwrap($body, 100); // Send the email: mail('$row[1]', 'Message from SplendedTopics.com', $body, "From: {$_POST['email']}"); // Print a message: echo '<p><em>Thank you for contacting a member of Spendid Topics.</em></p>'; // Clear $_POST (so that the form's not sticky): $_POST = array(); } else { echo '<p style="font-weight: bold; color: #C00">Please fill out the form completely.</p>'; } } // End of main isset() IF. ?> <p>Please fill out this form to contact the poster of this notice.</p> <form action="EmailContactPoster.php" method="post"> <p>Your Name: <input type="text" name="name" size="30" maxlength="60" value="<?php if (isset($_POST['name'])) echo $_POST['name']; ?>" /></p> <p>Your Email Address: <input type="text" name="email" size="30" maxlength="80" value="<?php if (isset($_POST['email]'])) echo $_POST['email']; ?>" /></p> <p>Comments: <textarea name="comments" rows="5" cols="30"><?php if (isset($_POST['comments'])) echo $_POST['comments']; ?></textarea></p> <input type="hidden" name="id" value="' . $id . '" /> <p><input type="submit" name="submit" value="Contact Poster!" /></p> </form>