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,
clicks on the name,
views the details as an email and a confirmation button,
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.
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";
$name
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.
Related
I'm working on building a database for a messaging system that will work more like an email rather than a Chat.
I've come across a little debate whether I should allow for the sender's name to be static or dynamic.
What I mean is, should I save the current user's display name as is when the message is sent or for the name to be pulled from the user's personal details? This means that if the user changes his/her display name, it would take effect on every message ever received by others.
In my project, I do not forsee users changing their display names frequently but it is bound to happen and I am not sure which approach to take.
The only thing that comes to mind is that if I do it dynamically, it could be confusing for someone to look for the messages of a given user and not find them because the name has changed.
Any pointers?
This will really come down to how you want your application to function. Both points you raised are valid.
If I were implementing this feature I believe I would go the route of having the usernames change dynamically. However I would save all past aliases of each user in a separate table, and have a page/widget that would display them. For example, when a user opens a message from x user they could hover over the name and all past aliases would show in a modal. Or they could click on the name, be directed to the user's profile where you would have a link that they could click on that took them to a page that showed all past user aliases.
I don't know if there is a easier way to do this, im starting out with php, I am trying to add a link to a email letter so that once the link is pressed it opens a webpage and auto submits a form to my email address with just a reference number that was added to the link.
I have tried a few ways with php but can only get a blank email to arrive.
Use an id(identifier) with the link. Use the id later to track who had opened the link.
When sending email add a parameter to link ("?referer=xyx23") and save the refere in database. When user opens the link you can track using the database the referer
You need add link with the unique get-parameter, like: http://your-site.com?sendemail=9adb879856464.
This parameter saved in the database. If user enters the site using link from email at the server run the script, this script checks, if is the link valid. If link is valid, check is the link in the database. If this link is in the database, then send the mail using php mail-function. If you want user used link once, delete the link in the database.
I have an application that works this way.
I have a users table in mysql with user id and all data
This is what happens:
a) A user signed up to my site(A) goes to another website(B) and answers some question.
b) The website(B) Sends me email with data of a user who is in my database.
now what i want to do is automatically whenever an eamil about a particular received in my inbox. The code in php detects the user id and saves the mail in emailrep field of my database.
Please tell me how can i achieve this in PHP???
I think this is a good start
Reading Emails with PHP
I'm working on a project to learn PHP, and I'm realizing I have a ways to go.
I'm creating a basic site that allows traditional account creation for a user to go in and build email lists. They can then send out an email that it personalizes and makes a form letter. At the end of this letter I am including a link that the reader can go to (unique to each person) where they can select and fill out a short form that I would like to be able to process back into another table in my database. All the while keeping track of who said what.
I have everything working perfectly right now, but I didn't realize until just barely that the only reason it works is because I was already authenticated as the main user (when I was opening up test emails and saving my responses). So when I open an email and go to the link and fill out the form on a computer that doesn't have any cookies or session variables cached, I can't save because I have no access to the database.
My question
The URL that shows up in each person's email has a guid at the end that is made up of a combination of things that uniquely identifies that person. I'd really prefer not to make the email recipients make an account with me, but I need to be able to process their responses.
How can I give them access to writing to the database even though they don't have full login credentials? I know that they are legitimate based on their URL, can that somehow be made to work?
EDIT: Some code
Here is an example of a URL in the email:
mysite.com/process.php?guid=abcdefghijklmnopqrstuvwxyz
When clicked, I pull the guid out of the $_GET and look up some information about it. Now that I think about it, it doesn't really make sense that I can look up stuff in the database off the bat, but that's another issue. After the form is filled out, and the save button pressed, this is what is going on:
<?php
drequire("library/database.inc.php");
require("library/check-user.inc.php");
include("library/head1.inc.php"); // Load meta data
include("library/head2.inc.php"); // Load scripts
include("library/header.inc.php"); // Load header
$email = $_POST['email'];
$eqp = $_POST['eqp'];
$month = $_POST['month'];
$sqlDel = "DELETE FROM results WHERE eqp = $eqp AND month = '$month' AND email = '$email'";
mysql_query($sqlDel) or die('Error, could not delete.');
$sqlIns = "INSERT INTO results (month, email, eqp) VALUES ('$month', '$email', $eqp);";
mysql_query($sqlIns) or die('Error, could not insert.');
echo'Success! Keep up the good work!';
?>
But the insert doesn't occur. I am assuming it is because I really don't have a connection to the database.
You need to post some code, but as a pseducode answer
function post_for_user_to_write($special_user_ID_in_email)
{
if ($special_user_ID_in_email == valid_special_ID())
{
// Connect to database
// Post data to database
}
}
I was asked by a person to create a php code, which is a part of a larger ERP software development project, so that he can test my skills. The code regarding a simple user authentication once the user registers through a form , by putting name, date of birth ,email.(which I have already done through html).
The action property of the html form, is a php file which consists of php code to get the posted inputs in the form, generate a verification link, and send it to the user via his/her email which he/she has already given.
I have two basic questions or problems:
How can this verification link be created?
Once the user clicks on this type of a link how does PHP know that they did so?
I don't think that there is any concept of event-driven programming in PHP. In that case, how does PHP handle that click and give a "conformational success message"? Is a MySQL database required or is there another easier way?
When you create the user, you are also going to generate a random string for that user. This is their authorization code. You will store it with the user's data in your database.
Then you are going to make your authorize page (ex., authorize.php). It will take a $_GET parameter of 'code', or whatever else you want (ex., authorize.php?code=theHashYouCreated). This page's code will look something like this:
if(!empty($_GET['code']))
{
/*
* Get the data from the database by the provided code.
* If a result is returned, then remove the authorization
* code from the user's record. If no user is found, then
* return an error.
*/
}
else
{
//No code was provided, so we should error.
}
Now, when the user tries to login you also want to check to see if their authorization code is set in the database. If it is, then they have not validated their e-mail address yet. If it isn't, then they have validated it.
Here's a nice tutorial that should help you create a confirmation email:
http://www.learnphponline.com/scripts/email-activation-for-php-forms
It involves creating a randomly generated activation key, that will initially be stored in the database. The key should be emailed to the user in the form of a GET parameter in a link.
Once the link is clicked, the submitted GET parameter is checked with the value in the database.