GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Tech Submission to SQL Database & Send Email? (https://gfy.com/showthread.php?t=1348801)

Publisher Bucks 10-01-2021 06:42 PM

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 :thumbsup

ZTT 10-01-2021 06:56 PM

Whatever you do, don't spend five seconds trying it before asking here. That would be crazy.

Publisher Bucks 10-01-2021 06:59 PM

Quote:

Originally Posted by ZTT (Post 22919981)
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.

ZTT 10-01-2021 07:37 PM

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");

sarettah 10-01-2021 07:54 PM

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);

}

sarettah 10-01-2021 07:59 PM

Never mind...

.

ZTT 10-01-2021 08:21 PM

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

sarettah 10-01-2021 08:29 PM

Quote:

Originally Posted by ZTT (Post 22920000)
Whatever you do, don't spend five seconds reading a four post thread before repeating what's in it. That would be crazy.

What?

.

ZTT 10-01-2021 08:42 PM

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?

sarettah 10-01-2021 08:53 PM

Quote:

Originally Posted by ZTT (Post 22920010)
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.

,

sarettah 10-01-2021 08:58 PM

Quote:

Originally Posted by ZTT (Post 22919990)

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.

.

Publisher Bucks 10-01-2021 09:00 PM

Quote:

Originally Posted by sarettah (Post 22919995)
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 10-01-2021 09:02 PM

Quote:

Originally Posted by ZTT (Post 22919990)
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 10-01-2021 09:22 PM

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 :thumbsup

Next on my list if the CRUD system which is almost done I just need to add a few stylesheets :)

ZTT 10-01-2021 09:25 PM

Quote:

Originally Posted by sarettah (Post 22920017)
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?


All times are GMT -7. The time now is 03:22 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123