Jump to content

Insert data, then send an e-mail?


Dennis Ingham

Recommended Posts

Hi

 

I'm creating a user registration form where I want these actions to run when a button is submitted:

 

1.  Insert data from form fields into my database (Mydb)

 

2.  When data is inserted, then send an e-mail with to the adress defined in one of the form fields. The e-mail is carrying a userid defined in one of form fields.

 

Right...what I want is to create a user. Insert the data into my table in my database. Then send en e-mail with the user-id (defined in my form) to a e-mail adress also defined in my form.

 

How do i do this?

 

Best regards

//Dennis

Link to comment
Share on other sites

Thats a lot to ask. Maybe you can start/attempt to write some code, and then we will guide you from there.

I will start you off.

If you have a table with username and password fields then to insert data into those fields you would use:

<?php

$username = mysql_real_escape_string($_POST['username']);
$pass = md5($_POST['password']);

$sql = "insert into users (username,password) values ('{$username}','{$pass}')";

mysql_query($sql);

?>

Link to comment
Share on other sites

Also, after you enter your information, to send an email you will use the following code:

 

mail ('mailto', 'subject', 'body');

 

Where mailto is who you want the email sent to, subject is the subject of the email and body is the message sent in the email. Each of those words can be replaced with whatever you choose, including variables that you set. Hope that helps some.

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.