I have a site that contain more than 10000 videos, and sometimes there is embeded video that doesnt work, i need to show to my visitors this message "click here if the video doesnt show anymore" and when they click to this message , i will recieve a notification from the page that has been clicked
I didnt found any joomla extension that can do this
If i put this php code in every page of my joomla website
<form action="" method="post">
<input type="submit" value="Send details to embassy" />
<input type="hidden" name="button_pressed" value="1" />
</form>
<?php
if(isset($_POST['button_pressed']))
{
$to = 'nobody#example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster#example.com' . "\r\n" .
'Reply-To: webmaster#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
echo 'Email Sent.';
}
?>
It will send me a message in one click.
How can i receive a mail containing the name of page where the user has clicked?
In Joomla with this html code we can obtain the name of the current page.
<? $doc =& JFactory::getDocument();
echo $doc->getTitle();?>
Something like
$message = 'Page:' . $doc->getTitle();
should do the trick.
Related
I want to have a page with some form inputs and with date picker i want to send these all fields to mail how to i do this with PHP?
You can do that by first getting what users typed in a form.
Then parse the input into a text file or html file that you can send using the mail() function in PHP.
for example for a "datepickerfield" field:
<?php
$to = 'nobody#example.com';
$subject = 'the subject';
$message = $_GET['datepickerfield'];
$headers = 'From: webmaster#example.com' . "\r\n" .
'Reply-To: webmaster#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
You can access the form input fields in PHP over $_GET or $_POST. This depends on your form.
<form action="/mail.php" method="get">
or
<form action="/mail.php" method="post">
Here's an example:
HTML Form:
<form action="/mail.php" method="post">
<label for="fullname">Full name:</label>
<input type="text" id="fullname" name="fullname">
<label for="birthday">Birthday:</label>
<input type="date" id="birthday" name="birthday">
<input type="submit" value="Submit">
</form>
and in your php file :
<?php
$to = 'nobody#example.com';
$subject = 'the subject';
$headers = 'From: webmaster#example.com' . "\r\n" .
'Reply-To: webmaster#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$message = 'The Birthday of '.$_POST['fullname'].' is: '.$_POST['birthday'];
mail($to, $subject, $message, $headers);
?>
Take a look at https://www.php.net/manual/en/function.mail.php
I'm trying to use the following code to try and send a PHP Email with a PDF attachment.
I get the message 'Mail Sent. Thank You'. However, No email is being sent.
Please could someone show me / explain to me where I am going wrong?
Thanks
<?php
if(isset($_POST['submit'])){
$to = "example#example.com"; // this is your Email address
$from = $_POST['email']; // this is the sender's Email address
$subject = "Subject Here";
$message = $_POST['message'];
$file = $_POST['upload'];
$headers = 'From: someone#gmail.com ' . "\r\n" .
'Reply-To: someone#gmail.com ' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$headers2 = "From:" . $to;
mail($to, $subject, $message, $file, $email, $headers);
echo "Mail Sent. Thank you.";
// You can also use header('Location: thank_you.php'); to redirect to another page.
}
?>
<!DOCTYPE html>
<head>
<title>Form submission</title>
</head>
<body>
<form action="" method="post">
Message:<br><textarea rows="5" name="message" cols="30"></textarea><br>
<input type="file" name="upload" accept="application/pdf,application/vnd.ms-excel" />
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
There are lot of issues with your code, and it is recommended to first check the syntax and documentation on official site. For instance your are passing $file as parameter to mail function, but there is no FILE parameter in mail function (https://www.php.net/manual/en/function.mail.php)
Then you are not saving the uploaded PDF to any disk to send from. Uploaded files are captured through $_FILES variable not $_POST variable. You need to see that too.
Then sending any file is tricky job, and your job can be ease by using some library function such as PHPMailer so try to refer those.
I'm trying to make an application to send emails when a button is clicked. I tried to use isset function to do that. But my code doesn't work well. How do I fix it?
Demo below:
<!-- <button name="sendemail">send</button> -->
<input type="submit" value="send"/>
<?php
if(isset($_POST['Submit'])){
?>
<?php
// multiple recipients
// $to = 'aidan#example.com' . ', ';
// $to .= 'wez#example.com';
$to="example#outlook.com";
// subject
$subject = 'test01';
// message
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
</body>
</html>
';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To: Mary <mary#example.com>, Kelly <kelly#example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive#example.com' . "\r\n";
mail($to, $subject, $message, $headers);
}
?>
You can use the below code to fire an email on click of the Send Email button
<form action="" method="post">
<input type="submit" value="Send details to college" />
<input type="hidden" name="button_pressed" value="1" />
</form>
<?php
if(isset($_POST['button_pressed']))
{
$to = 'nobody#example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster#example.com' . "\r\n" .
'Reply-To: webmaster#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
echo 'Email Sent.';
}
?>
A couple of things to address here. First, your input button doesn't do anything, because it isn't a part of a form. So you either have to use some sort of JavaScript or just a HTML form to submit the button to, so we can process it in PHP. A simple form is done like this below. Note the metohd="POST", this allows us to gather the information from the $_POST-array in PHP later on (by default forms are set to use GET).
<form method="POST">
<input type="submit" name="submit" value="Send!" />
</form>
This form will send the data over the POST-array, to the same page it's placed on, so place your PHP here as well.
Secondly, you did not have a name attribute in your submit-button, and since PHP uses the names rather than the IDs (like JavaScript does), you need to add this. This can be seen in the code-snippet above.
Further, you never check if the mail was actually sent or not. You should never take anything for granted.
<?php
if (isset($_POST['submit'])) {
/* add headers, messages and such here */
// Check if the mail is being sent from the server
if (mail($to, $subject, $message, $headers)) [
// Mail was sent! Great!
} else {
// It failed sending the mail
}
}
?>
You'll need to set the name attribute for your input element, and the input element need to be in a form. Also, the $_POST['submit'] should be in lowercase to keep it consistent.
You should also check to see if mail() is sent successfully. mail() will return true when sent and false if not sent.
Just a note, the actual sending of mail will depend on your hosting/ server, even if it returns true, it does not necessarily mean that the mail is sent.
Find out more about mail() at http://php.net/manual/en/function.mail.php.
The following code should work:
<form method="post">
<input type="submit" name="submit" value="send" />
</form>
<?php
if(isset($_POST['submit'])){
// NO Change from your original code
if(mail($to, $subject, $message, $headers)) {
// You can change this to whatever you want PHP to do when mail is successfully sent
echo 'Mail successfully sent';
} else {
// You can change this to whatever you want PHP to do when mail failed to send
echo 'Mail failed to send';
}
?>
Hope this helps. Thanks!
I have mail.php which sends out an email. This is the code I'm using.
<?php
if(isset($_POST['submit'])){
$to = $_POST['email'];
$subject = 'Your Results!';
$message = $_POST['message'];
$headers = 'From: example#example.com' . "\r\n" .
'Reply-To: example#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
//mail($to, $subject, $message, $headers);
//header("Location: thankyou.php");
echo $message;
}
?>
The contents of the email is supposed to the .innerText of of a div I have on my index.php page. If I echo out the message, then the output appears the page (mail.php) but when I comment/uncomment the necessary parts to email myself the message I receive is just "undefined".
Is $message not defined?
Here is the form and javascript I'm using
<form action="mail.php" method="post" onsubmit="this.message.value = document.getElementById('box').innerText;">
<input type="email" name="email" required>
<input id="content" type="hidden" name="message" value="">
<input type="submit" name="submit">
</form>
Change .innerText to .textContent. .innerText is a nonstandard property that doesn't exist in Firefox.
I don't know why you didn't have the same problem when used echo $message in the PHP script, unless you tested that version of the script with a different browser (always try to minimize the number of differences when you're testing like this).
I'm creating 4 button on a webpage for a building entrance. I'm using 'awesome menu' as the page layout like the demo http://line25.com/wp-content/uploads/2009/css-menu/demo/demo.html
So each menu button is clicked, an email is sent to an appropriate department automatically. Eg Ninja button is clicked, an email is sent to ninja#example.com
I've got my php form I'm thinking of using to send emails, my question is that how can combine my php form with this menu list code? I'm a bit lost so any help is appreciated.
Here is my code for the page layout, an image is attached to each button using css like the awesome menu demo download code.
<body>
<ul id="awesome-menu">
<li>Ninja</li>
<li>Zombie</li>
</ul>
</body>
And here is the php form code I'm thinking of using to send emails
<form action="" method="post"> //for first list
<input type="submit" value="Send details" />
<input type="hidden" name="button_a" value="1" />
</form>
<?php
if(isset($_POST['button_a']))
{
$to = 'ninja#example.com';
$subject = 'You have a visitor';
$message = 'hello I am here to see ninja';
$headers = 'From: webmaster#site.com' . "\r\n" .
'Reply-To: webmaster#site.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
echo 'Email Sent A.';
}
?>
//for second list
<form action="" method="post">
<input type="submit" value="Send details to b" />
<input type="hidden" name="button_b" value="1" />
</form>
<?php
if(isset($_POST['button_b']))
{
$to = 'zombie#example.com';
$subject = 'You have a visitor';
$message = 'hello I am here to see zombie';
$headers = 'From: webmaster#site.com' . "\r\n" .
'Reply-To: webmaster#site.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
echo 'Email Sent.';
}
?>
You could try something like this:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<ul id="awesome-menu">
<li>
<form action="emailAndRedirect.php" id="ninja" method="post">
<input type="hidden" name="name" value="ninja" />
</form>
Ninja
</li>
<li>
<form action="emailAndRedirect.php" id="ninja" method="post">
<input type="hidden" name="name" value="zombie" />
</form>
Zombie
</li>
</ul>
<script type="text/javascript">
function formSubmit(name)
{
if (name == 'ninja') {
document.getElementById("ninja").submit();
} else if (name == 'zombie') {
document.getElementById("zombie").submit();
}
}
</script>
</body>
</html>
And in your php:
<?php
$url = //url of the page you wan t
if (isset($_POST['name'])) {
$name = $_POST['name'];
if ($name == 'ninja') {
$email = 'ninja#example.com';
} else if ($name == 'zombie') {
$email = 'zombie#example.com';
}
}
$to = $email;
$subject = 'You have a visitor';
$message = 'hello I am here to see $name';
$headers = 'From: webmaster#site.com' . "\r\n" .
'Reply-To: webmaster#site.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
header('Location: $url#$name');
?>
Edit: Thjs uses javascript, so you would be reliant on it. With a javascript form submit function you would be able to keep the same links and styling and still submit the forms.