Thanks, its not that I am not concerned about it, its just that do to time limits I only want to investigate further when I have time.
Guess what. Someone gave me this, maybe you guys who were so nice to help me maybe you can use it too. This does the same thing as the php self without the php self. Who knew that if you left the form action blank like this, it would post on the same page anyway. action="" I have been messing with trying to code the php self just so for a few days. This stops all of it. Can you guys see any reason why I shouldn't use it? But whats also nice about the following is that the form fields not only appear on the page it sends to an email as well which is what I was looking for.
<?php
if($_POST['text']=="")
{
echo'
<form method="post" action=""><input type="text" name="text"><br /><br /><input type="submit" value="submit"></form>
';
}
else
{
echo $_POST['text'];
$mailto = 'emailaddress@website.com';
$sendfield = $_POST['text'];
$subject = 'Email subject';
$from = "From: ".$sendfield. "\n" ;
$messageproper = 'Field sent to this email: '.$sendfield.'\n';
mail($mailto,$subject,$messageproper,$from);
echo'
email sent';
}
?>
So now I only need help with one small thing from someone please, I'll really appreciate it. I am trying to use the just above code that carries an item over from a database. Normally it looks something like this and works with the usual database items above it.
$query = "SELECT websitename FROM checkname WHERE websitename = '$modify'";
$result = mysql_query($query) or die('Error with query' . mysql_error());
if (mysql_num_rows($result) == 0)
{
echo "$modify not found, please recheck name.
Just click the 'back' button to try again.";
}
while ($row = mysql_fetch_array($result))
{
echo"<form action="" method='post'>
etc .
But now that I want to use the just above new code after the database info, I added it like this.
$query = "SELECT websitename FROM addscript WHERE websitename = '$modify'";
$result = mysql_query($query) or die('Error with query' . mysql_error());
if (mysql_num_rows($result) == 0)
{
echo "$modify not found, please recheck name.
Just click the 'back' button to try again.";
}
if
($_POST['text']=="")
{
echo '
<form method="post" action=""><input type="text" name="text"><br /><br /><input type="submit" value="submit"></form>
';
}
else
{
echo $_POST['text'];
$mailto = 'emailaddress@website.com';
$sendfield = $_POST['text'];
$subject = 'Email subject';
$from = "From: ".$sendfield. "\n" ;
$messageproper = 'Field sent to this email: '.$sendfield.'\n';
mail($mailto,$subject,$messageproper,$from);
echo'
email sent
';
}}
?>
If you notice in order to accomodate the new code I changed this
while ($row = mysql_fetch_array($result))
{}
To this
while ($row = mysql_fetch_array($result)){
if($_POST['text']==""){
echo '
I put the if INSIDE the "while" statement, which seems like it should be the proper way but tell me if I'm wrong.
But now when text is entered I get 5 results on the page and to the email instead of only one.
When the form works all alone it doesn't do this, but when I add it after the database info it duplicates. Need it to be only one. Can someone see the duplication erro? I can't see it.
Help is appreciated. Thank you very much.