confirming message before mailing in php

2020-05-09 22:45发布

问题:

I'm developing a website where in it will list names from database as links. I'm already up to the point that when one user clicks on the name, it will pass the name's details to another page to view the email format etc. I just need a suggestion on how I can do this as I'm not an expert with php yet. I'm still studying more advanced codes. So,

  1. clicks on the name,
  2. views the details as an email and a confirmation button,
  3. send the mail. I just need suggestions on how to make this easy. I am getting to know the script for mail(). Thanks

EDIT : Since, there are a lot who think it's confusing. I just need advice on how I will pass data from one page to another then email.

回答1:

What do you mean by getting the names as links?. do you have the link field in the database which is retrieved along with the name?

This is the solution based on what I understand from your vague question:

You have names which are retrieved from the database. Also retrive the id from the database. Display these names as links pointing to a different PHP page. lets name the php page as user.php. so the link will be:

$name = "You go this name from USER TABLE";
$id = "YOU GOT THIS ID FROM USER TABLE";
<a href="/user.php?userID=<?php echo $id  ?>">$name</a>

Now in your user.php, retrive the id

$name = $_GET["userID"]; // make sure you do some parsing to avoid sql injection

// Retrieve all the information about this guy like email address etc from the database
// put everything into a form with a Confirm button which when clicked will mail it to the individual
// I think you should be able to figure out the mail part.