I was not sure how to name this topic, and I also couldn't think of a term to search for to find the answer, so I apologize now if the answer is already on here.

I have a form and this is the code:

<form action="http://wwtele.com/cgi-sys/formmail.pl" method="post" name="Contact" dir="ltr" lang="en">
<input type="hidden" name="recipient" value="MYEMAIL">
<input type="hidden" name="subject" value="SUBJECT LINE">
<input type=hidden name="redirect" value="REDIRECT PAGE">
        Name:<input name="realname" type="text" size="30" />
        <input type="hidden" type="text" value="REAL-NAME-VALUE-HERE" name="name" />
        Phone:<input name="Phone-Number" type="text" id="Phone-Number" tabindex="2" size="30" />
        Email:<input name="Email" type="text" id="Email" tabindex="3" size="30" />
        Message:<textarea name="Message" cols="30" rows="4" id="Message" tabindex="4"></textarea>
        <input type="submit" name="Submit" id="Submit" value="Submit" />
        <input type="reset" name="Reset" id="Reset" value="Reset" />
</form>

That is the code for the whole form.

<input name="realname" type="text" size="30" />

That section of the code is used by the form script so that the persons name gets put into the "From:" on the email that is sent to me. The problem is, then it does not show their name in the email, just the from line. I would like for it to be in the email aswell.
That is what I hoped I could use this line for:

<input type="hidden" type="text" value="REAL-NAME-VALUE-HERE" name="name" />

I was hoping that I could some how use PHP (or another language, I just figured PHP was the one to use) to put their name in a variable and then into the value for that text field so that their name shows in the email.
So I basically want their name to be copied and pasted into the value section of this field.

Any help on this matter would be appreciated.
Key

do you mean you wish to use PHP instead of this "http://wwtele.com/cgi-sys/formmail.pl" ?

this part of your form is very confusing

Name:<input name="realname" type="text" size="30" />
        <input type="hidden" type="text" value="REAL-NAME-VALUE-HERE" name="name" />

do you mean you wish to use PHP instead of this "http://wwtele.com/cgi-sys/formmail.pl" ?

this part of your form is very confusing

Name:<input name="realname" type="text" size="30" />
        <input type="hidden" type="text" value="REAL-NAME-VALUE-HERE" name="name" />

Sorry, I tried to make it not confusing. No, I still need to use "http://wwtele.com/cgi-sys/formmail.pl" to have the form contents submitted to my email.

Name:<input name="realname" type="text" size="30" />
        <input type="hidden" type="text" value="REAL-NAME-VALUE-HERE" name="name" />

The first input shows, and it is for the person to put their name in. The form script that I use also uses this field and puts the value into the From part of the email, so it looks like it is from that person who submitted the form.

The second input is hidden, and it is so that the persons name is included in the body of the email (because the other field only goes into the From section, not the body). I need to somehow "copy" the persons name and have it put into the value for this field so that the persons name is in the body of the email.

I hope that clears it up a little.

i suppose you do not have control over that script, so your only approach is to create a form with on text type input field, have it ask for a name , then have it submitted and processed by a PHP script that would create the real email form with the proper value for that hidden type input you added.

i suppose you do not have control over that script, so your only approach is to create a form with on text type input field, have it ask for a name , then have it submitted and processed by a PHP script that would create the real email form with the proper value for that hidden type input you added.

Yes, you assume correctly, I don't have access to change the script. So with the method that you suggest, I would first have one form, and have them enter their name, and have PHP pass their name to a variable that can be used in the other form? If that is the case, I am afraid I don't have enough PHP knowledge to do that.

it's not very complicated really

try creating this page "mail.php" and put the following code inside it

<html>
<head>
</head>
<body>
<?php

if(isset($_POST['name']) && $_POST['name'] != '')
{
	$name = $_POST['name'];		
	$mail_form = <<<EOF
<form action="http://wwtele.com/cgi-sys/formmail.pl" method="post" name="Contact" dir="ltr" lang="en">
<input type="hidden" name="recipient" value="MYEMAIL">
<input type="hidden" name="subject" value="SUBJECT LINE">
<input type=hidden name="redirect" value="REDIRECT PAGE">
        Name:<input name="realname" type="text" value="$name" size="30" /><br />
        <input type="hidden" value="$name" name="name" />
        Phone:<input name="Phone-Number" type="text" id="Phone-Number" tabindex="2" size="30" /><br />
        Email:<input name="Email" type="text" id="Email" tabindex="3" size="30" /><br />
        Message:<textarea name="Message" cols="30" rows="4" id="Message" tabindex="4"></textarea><br /><br />
        <input type="submit" name="Submit" id="Submit" value="Submit" />
        <input type="reset" name="Reset" id="Reset" value="Reset" />
</form>
EOF;
	
	echo $mail_form;
}
else
{	
	$self = $_SERVER['PHP_SELF'];
	$name_form = <<<EOF
<form name="name_form" action="$self" method="post">
<label for="name">Name: </label><input type="text" size="30" name="name" id="name" /><br />
<input type="submit" name="Submit" id="Submit" value="Get Mail Form" />
</form>
EOF;

	echo $name_form;
}
?>
</body>
</html>

hope this helps :)

Been a little busy lately, but I tested your code that you gave me and it works completely. Thanks so much for your help.

$name = $_POST['name'];

It really helped me to use the value of the html form as a variable in php...Thanks a lot..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.