PHP, change mailing list sender.
This is the following code i made for my mailing list,
i dont want the info to be stored in the url but in
variables or something else inside the file, hidden.
how do i do that and what do i change to what?
would really apperentice help. Greetings Adrian
Code:
<?php
require('../../style/database.php');
require('../../style/smtp.php');
//form data
$message = mysql_real_escape_string(strip_tags($_POST['message']));
$mailcount = 0;
$namecount = 0;
$get = mysql_query("SELECT * FROM users WHERE news='1'");
echo "<form action='' method='$_POST'>";
while ($getrow = mysql_fetch_assoc($get)){
echo"<input type='checkbox' name='mail_".$mailcount++."' value='".$getrow['email']."'
CHECKED>".$getrow['firstname']." ".$getrow['lastname']." (".$getrow['email'].")
<input type='hidden' name='name_".$namecount++."' value='".$getrow['firstname']." ".$getrow['lastname']."'><br>";}
echo "<p></p>Message to our users:<br>
<textarea name='message' rows='10' cols='30'></textarea><p></p>
<input type='submit' name='submit' value='Send Message'></form>";
if ($submit){
//loop through
for($x=0;$x<count($_GET);$x++){
if ($_GET["mail_$x"]){
//mail setup
$to = $_GET["mail_$x"];
$subject = "Newsletter";
$message = $_GET['message'];
$body = "Dear ".$_GET["name_$x"]."\n\n $message";
$header = "From: Adrian@localhost.com";
mail($to, $subject, $body, $header);}}
echo "All mail has been processed.";}?>
Re: PHP, change mailing list sender.
Re: PHP, change mailing list sender.
you mean you want to hide the mailing route? sounds like you want to do something illegal and immoral.
Re: PHP, change mailing list sender.
I believe he's talking about the content under //mail setup
He doesn't want his email info to be set in url variables.
Since you are submitting the message with a form, you could put the email info into hidden inputs in your form.
Code:
<input type="hidden" name="subject" value="Newsletter" />
That would output on the script page as
:thumbup1:
Re: PHP, change mailing list sender.
@foxx: ill try to explain better mate.
@MetaL: god no, thats really not what i ment:o
@chrisdothtml: yeah something like that.
i open my document [http://localhost/admin/newsletter/]
the only user found is: Adrian Ronsten (netsnor@gmail.com)
and when i click send message i get this url:
[http://localhost/admin/newsletter/in...=Send+Message]
and what im asking is how do i replace the red part
[http://localhost/admin/newsletter/index.php?mail_0=netsnor%40gmail.com&name_0=Adrian+Ronsten&message=&submit=Send+Message]
and store the information inside the document instead of like i do now, in the urlbar.
Re: PHP, change mailing list sender.
Submit using POST not GET?
Re: PHP, change mailing list sender.
Yeah, just use POST not GET.
GET is for when you're not using forms or want a variable to be in the URL for whatever reason, like dynamically generating links.
Re: PHP, change mailing list sender.
On your form, the method of posting is GET, you need POST.
When creating your form, use this:
Code:
<form action="page to submit to" method="POST">
</form>
Re: PHP, change mailing list sender.
And i noticed this little code:
Code:
echo "<form action='' method='$_POST'>";
I think thats really not the way you want to write it.
It should be <form action="" method="post">. (And since you wrote wrong, all data gets sent by the GET method, which is default).
Re: PHP, change mailing list sender.
Quote:
Originally Posted by
Erlend
And i noticed this little code:
Code:
echo "<form action='' method='$_POST'>";
I think thats really not the way you want to write it.
It should be <form action="" method="post">. (And since you wrote wrong, all data gets sent by the GET method, which is default).
I didn't even notice that.
That'll do it.