Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 10-01-2021, 06:42 PM   #1
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,126
Submission to SQL Database & Send Email?

How would I go about changing my submission.php coding so that when someone sends info across to the database, it also sends me an email to let me know?

This is my submission.php file contents presently:

Quote:
<?php
$link = mysqli_connect("localhost", "database", "password", "username");

// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}

// Escape user inputs for security
$title = mysqli_real_escape_string($link, $_REQUEST['title']);
$recipe = mysqli_real_escape_string($link, $_REQUEST['recipe']);
$description = mysqli_real_escape_string($link, $_REQUEST['description']);
$category = mysqli_real_escape_string($link, $_REQUEST['category']);
$name = mysqli_real_escape_string($link, $_REQUEST['name']);
$email = mysqli_real_escape_string($link, $_REQUEST['email']);

// Attempt insert query execution
$sql = "INSERT INTO Directory (title, recipe, description, category, name, email) VALUES ('$title', '$recipe', '$description', '$category', '$name', '$email')";
if(mysqli_query($link, $sql)){
echo "Records added successfully.";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}

// Close connection
mysqli_close($link);
?>4
Am I able to just fuck with the code from my feedback form code and append it onto the end of the code in submission.php above?

Quote:
<?php
if(isset($_POST['email'])) {

// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "[email protected]";
$email_subject = "New Recipe Submission";

}
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
Any pointers in the right direction would be appreciated
Publisher Bucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-01-2021, 06:56 PM   #2
ZTT
Confirmed User
 
ZTT's Avatar
 
Industry Role:
Join Date: Apr 2019
Posts: 657
Whatever you do, don't spend five seconds trying it before asking here. That would be crazy.
__________________
__________________
ZTT is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-01-2021, 06:59 PM   #3
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,126
Quote:
Originally Posted by ZTT View Post
Whatever you do, don't spend five seconds trying it before asking here. That would be crazy.
I have tried and its not working, I'm asking if there is another option to just appending and showing what I already tried.
Publisher Bucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-01-2021, 07:37 PM   #4
ZTT
Confirmed User
 
ZTT's Avatar
 
Industry Role:
Join Date: Apr 2019
Posts: 657
Have you have tested your email form so you know it definitely works? Some servers may block it, and some email providers may not accept such email. If it works - that is you submit a form and receive an email - there should be no issue with using the mail function when people submit data.

BTW you don't need all that header shit on an email. You need To, Subject, Message, From. For example this is probably enough to test with (obviously with real email addresses), after or before your "records added successfully" line:

mail("me@myhouse","Hello","How are you","From: you@yourhouse");

Edit: since newlines may be necessary, even with one line of headers (from): mail("me@myhouse","Hello","How are you","From: you@yourhouse\r\n");
__________________
__________________
ZTT is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-01-2021, 07:54 PM   #5
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,072
I would do it inside the if checking results from the query.

if(mysqli_query($link, $sql)){
echo "Records added successfully.";

// ...............Do the email shit right here................

$emailsubj="subject of my email";

$emailsendaddress="[email protected]";

$emailaddy2use="address I am sending to";

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .="From: " . $emailsendaddress . "\r\n";

mail ( $emailaddy2use, $emailsubj, $emailmessage, $headers);

}
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-01-2021, 07:59 PM   #6
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,072
Never mind...

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-01-2021, 08:21 PM   #7
ZTT
Confirmed User
 
ZTT's Avatar
 
Industry Role:
Join Date: Apr 2019
Posts: 657
Whatever you do, don't spend five seconds reading a four post thread before repeating what's in it. That would be crazy.
__________________
__________________
ZTT is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-01-2021, 08:29 PM   #8
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,072
Quote:
Originally Posted by ZTT View Post
Whatever you do, don't spend five seconds reading a four post thread before repeating what's in it. That would be crazy.
What?

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-01-2021, 08:42 PM   #9
ZTT
Confirmed User
 
ZTT's Avatar
 
Industry Role:
Join Date: Apr 2019
Posts: 657
I said:

Whatever you do, don't spend five seconds reading a four post thread before repeating what's in it. That would be crazy.

Do you get paid per sig view?
__________________
__________________
ZTT is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-01-2021, 08:53 PM   #10
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,072
Quote:
Originally Posted by ZTT View Post
I said:

Whatever you do, don't spend five seconds reading a four post thread before repeating what's in it. That would be crazy.

Do you get paid per sig view?
What the fuck are you talking about?

Where, in the posts before mine, do you tell him that you would move the email send into the if statement testing the query, or anything like that.

Dude asked:
How would I go about changing my submission.php coding so that when someone sends info across to the database, it also sends me an email to let me know?

And later said:
I'm asking if there is another option to just appending and showing what I already tried.

I gave him another option, moving it into the if statement after the query rather than doing another if.

So, where the fuck did I repeat everything that is already in the thread? The email shit, I just pasted that in there to demonstrate where I would drop it in.

Now, you have a problem with me? I suggest you ignore me.

Oh, yeah. Go Fuck Yourself, asshole.

,
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-01-2021, 08:58 PM   #11
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,072
Quote:
Originally Posted by ZTT View Post

after or before your "records added successfully" line:
Ok, I just saw that when I looked really hard, I had gone past it earlier because it was combined in with another idea.

Sorry about that.

Still, fuck you for being an asshole about it.

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-01-2021, 09:00 PM   #12
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,126
Quote:
Originally Posted by sarettah View Post
I would do it inside the if checking results from the query.
Can I ask why there? Is there a specific reason or is that just the 'correct' way of doing it?
Publisher Bucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-01-2021, 09:02 PM   #13
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,126
Quote:
Originally Posted by ZTT View Post
Have you have tested your email form so you know it definitely works? Some servers may block it, and some email providers may not accept such email. If it works - that is you submit a form and receive an email - there should be no issue with using the mail function when people submit data.

BTW you don't need all that header shit on an email. You need To, Subject, Message, From. For example this is probably enough to test with (obviously with real email addresses), after or before your "records added successfully" line:

mail("me@myhouse","Hello","How are you","From: you@yourhouse");

Edit: since newlines may be necessary, even with one line of headers (from): mail("me@myhouse","Hello","How are you","From: you@yourhouse\r\n");
Yes, the form works on several other sites that I have it on, which was why I'm choosing to use this specific form

Thank you.
Publisher Bucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-01-2021, 09:22 PM   #14
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,126
Moving it to that position worked great and I even managed to add a html template page to the bottom of the code so it matches the rest of the site layout.

Thank you both for the assistance

Next on my list if the CRUD system which is almost done I just need to add a few stylesheets
Publisher Bucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-01-2021, 09:25 PM   #15
ZTT
Confirmed User
 
ZTT's Avatar
 
Industry Role:
Join Date: Apr 2019
Posts: 657
Quote:
Originally Posted by sarettah View Post
Ok, I just saw that when I looked really hard, I had gone past it earlier because it was combined in with another idea.

Sorry about that.

Still, fuck you for being an asshole about it.

.
I'm an asshole for making a jokey callback to something I posted to the OP (who unlike you didn't have a total meltdown about it) because reading a four post thread before posting to it is "really hard" for you?
__________________
__________________
ZTT is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks

Tags
submission.php, email, database, sends, file, contents, presently, info, send, sql, submission, coding, changing



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.