Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PHP form script

Featured Replies

hello new in php and i have a lot of problems.this is my form:

 

 

 

<form action="form1.php" method="post" name="form1" target="_blank" id="form1">

<table width="90%" height="394" border="0" cellpadding="0" cellspacing="0">

<tr>

<td width="34%" height="65" valign="bottom"><span class="style8">First Name</span></td>

<td width="66%" valign="bottom"><input name="Firstname" type="text" id="Firstname" size="40" /></td>

</tr>

<tr>

<td><em><strong><span class="style9">Last Name</span></strong></em></td>

<td><input name="Lastname" type="text" id="Lastname" size="40" /></td>

</tr>

<tr>

<td><em><strong><span class="style9">Country</span></strong></em></td>

<td><input name="Country" type="text" id="Country" size="40" /></td>

</tr>

<tr>

<td><em><strong><span class="style9">City or village</span></strong></em></td>

<td><input name="Cityorvillage" type="text" id="Cityorvillage" size="40" /></td>

</tr>

<tr>

<td><em><strong>Street-number</strong></em></td>

<td><input name="Streetnumber" type="text" id="Streetnumber" size="40" /></td>

</tr>

<tr>

<td><em><strong><span class="style9">Post code</span></strong></em></td>

<td><input name="Postcode" type="text" id="Postcode" size="40" /></td>

</tr>

<tr>

<td><em><strong><span class="style9">E-mail</span></strong></em></td>

<td><input name="Email" type="text" id="Email" size="40" /></td>

</tr>

<tr>

<td><em><strong><span class="style9">Phone number</span></strong></em></td>

<td><input name="Phonenumber" type="text" id="Phonenumber" size="40" /></td>

</tr>

<tr>

<td><em><strong><span class="style9">Company name</span></strong></em></td>

<td><input name="Companyname" type="text" id="Companyname" size="40" /></td>

</tr>

<tr>

<td height="77"><em><strong><span class="style9">Comments and orders</span></strong></em></td>

<td><textarea name="Commentsandorders" cols="45" rows="5" id="Commentsandorders"></textarea></td>

</tr>

<tr>

<td height="58"><div align="center">

<input type="submit" name="button" id="button" value="Submit" />

</div></td>

<td><input type="reset" name="button2" id="button2" value="Reset" /></td>

</tr>

</table>

</form>

 

 

 

And this php code

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-7" />

<body>

 

<?php

 

//collect data

$f_Firstname=$_POST["f_Firstname"];

$f_Lastname=$_POST["f_Lastname"];

$f_Country=$_POST["f_Country"];

$Cityorvillage=$_POST["Cityorvillage"];

$Streetnumber=$_POST["Streetnumber"];

$Postcode=$_POST["Postcode"];

$Email=$_POST["Email"];

$Phonenumber=$_POST["Phonenumber"];

$Companyname=$_POST["Companyname"];

$Commentsandorders=$_POST["Commentsandorders"];

 

 

$check1=$_POST["int1"];

$check2=$_POST["int2"];

$check3=$_POST["int3"];

$check4=$_POST["int4"];

$check5=$_POST["check5"];

$check6=$_POST["check6"];

$check7=$_POST["check7"];

$check8=$_POST["check8"];

$check9=$_POST["check9"];

$check10=$_POST["check10"];

 

 

//form body text

$body = "Στοιχεία Ενδιαφέροντος\n\n";

$body .= "ονομα: $f_Firstname\n";

$body .= "επωνυμο: $f_Fastname\n";

$body .= "χωρα: $f_Country\n";

$body .= "Πολη η χωριο: $Cityorvillage\n";

$body .= "Οδος και αριθμος: $Streetnumber\n";

$body .= "Ταχ.κωδικος: $Postcode\n";

$body .= "E-mail: $Email\n";

$body .= "Τηλεφωνο: $Phonenumber\n";

$body .= "Εταιρια: $Companyname\n";

$body .= "Σχολια: $Commmentsandorders\n\n";

 

 

 

 

//send e-mail

/* To send HTML mail, you can set the Content-type header. */

//$headers = "MIME-Version: 1.0\r\n";

//$headers .= "Content-type: text/html; charset=iso-8859-7\r\n";

 

 

 

 

/* and now mail it */

//mail($to, $subject, $message, $headers);

 

 

$_email="panos@24kworld.com";

$_r=mail($_email, "Forma Endiaferontos", $body);

 

if($_r)

{

//response

echo("<p>e-mail has been succesfully sent<br>Thnaks for contact us</p>");

 

}

else

{

//response

echo("<p>E-mail has not been sent</p>");

}

 

$_email="pavlos@24kworld.com";

mail($_email, "Φόρμα Ενδιαφέροντος", $body);

?>

 

 

 

</body>

</head>

</html>

 

 

 

But it doesnt worl.I know i have mistakes in code but what????

Hi you html is calling the name Firstname

 

<td width="66%" valign="bottom"><input name="Firstname" type="text" id="Firstname" size="40" /></td>

 

php is calling the name f_firstname these need be the same

 

$f_Firstname=$_POST["f_Firstname"];

 

also you are using double quotes ["postname"];

 

try chaneging to single qutoes ['postname'];

 

check all your names for this error

 

also you dont seem to have ended the form </form>

 

i am in but of a rush at the moment so if you have any problems still pm me i will write you a php script for the html

 

also check your server settings for the sending of mail one of my hosting company doesent accept the mail fuction

 

make sure your php script is in a file called form1.php

 

good luck

  • Author
Hi you html is calling the name Firstname

 

<td width="66%" valign="bottom"><input name="Firstname" type="text" id="Firstname" size="40" /></td>

 

php is calling the name f_firstname these need be the same

 

$f_Firstname=$_POST["f_Firstname"];

 

also you are using double quotes ["postname"];

 

try chaneging to single qutoes ['postname'];

 

check all your names for this error

 

also you dont seem to have ended the form </form>

 

i am in but of a rush at the moment so if you have any problems still pm me i will write you a php script for the html

 

also check your server settings for the sending of mail one of my hosting company doesent accept the mail fuction

 

make sure your php script is in a file called form1.php

 

good luck

i made it work with your advices.But....it doesnt post the text that user inputs in form fields....!

I see a mail with only the description of each field.

 

The script is like this now

 

 

 

<?php

 

//collect data

$Firstname=$_POST['Firstname'];

$Lastname=$_POST['Lastname'];

$Country=$_POST['Country'];

$Cityorvillage=$_POST['Cityorvillage'];

$Streetnumber=$_POST['Streetnumber'];

$Postcode=$_POST['Postcode'];

$Email=$_POST['Email'];

$Phonenumber=$_POST['Phonenumber'];

$Companyname=$_POST['Companyname'];

$Commentsandorders=$_POST['Commentsandorders'];

 

 

$check1=$_POST['int1'];

$check2=$_POST['int2'];

$check3=$_POST['int3'];

$check4=$_POST['int4'];

$check5=$_POST['check5'];

$check6=$_POST['check6'];

$check7=$_POST['check7'];

$check8=$_POST['check8'];

$check9=$_POST['check9'];

$check10=$_POST['check10'];

 

 

//form body text

$body = 'Στοιχεία Ενδιαφέροντος\n\n';

$body .= 'ονομα: $Firstname\n';

$body .= 'επωνυμο: $Lastname\n';

$body .= 'χωρα: $Country\n';

$body .= 'Πολη η χωριο: $Cityorvillage\n';

$body .= 'Οδος και αριθμος: $Streetnumber\n';

$body .= 'Ταχ.κωδικος: $Postcode\n';

$body .= 'E-mail: $Email\n';

$body .= 'Τηλεφωνο: $Phonenumber\n';

$body .= 'Εταιρια: $Companyname\n';

$body .= 'Σχολια: $Commmentsandorders\n\n';

 

 

//send e-mail

/* To send HTML mail, you can set the Content-type header. */

//$headers = "MIME-Version: 1.0\r\n";

//$headers .= "Content-type: text/html; charset=iso-8859-7\r\n";

 

 

 

 

/* and now mail it */

//mail($to, $subject, $message, $headers);

 

 

$_email="panos@24kworld.com";

$_r=mail($_email, "Forma Endiaferontos", $body);

 

if($_r)

{

//response

echo("<p>e-mail has been succesfully sent<br>Thanks for contact us</p>");

 

}

else

{

//response

echo("<p>E-mail has not been sent</p>");

}

 

$_email="pavlos@24kworld.com";

mail($_email, "Φόρμα Ενδιαφέροντος", $body);

?>

Ok keep it simple at first while you learn

 

<?php

 

//collect data

$f_Firstname=$_POST['Firstname'];

$f_Lastname=$_POST['Lastname'];

$f_Country=$_POST['Country'];

$Cityorvillage=$_POST['Cityorvillage'];

$Streetnumber=$_POST['Streetnumber'];

$Postcode=$_POST['Postcode'];

$Email=$_POST['Email'];

$Phonenumber=$_POST['Phonenumber'];

$Companyname=$_POST['Companyname'];

$Commentsandorders=$_POST['Commentsandorders'];

 

$message="

First name

$f_Firstname

Lastname

$f_Lastname

Country

$f_Country

City

$Cityorvillage

Street number

$Streetnumber

Post Code

$Postcode

Email

$Email

Phone number

$Phonenumber

Company Name

$Companyname

Comments

$Commentsandorders

";

$subject="TEst";

 

 

 

ini_set("sendmail_from", "panos@24kworld.com");//you can delete this line if need be i have to use it on 1 of my hosting companies other wise it wont work

 

mail( "panos@24kworld.com",$subject,

$message );

 

echo "form sent";

 

?>

i have it working on my site of te html form you posted

 

now you need to think about making it spam proof a bit late now but will help if you ever need to send photos etc i have just written a contact form tonight for sending images that have been uploaded

 

this is the results of my site

 

First name

chris

Lastname

*****

Country

United Kingdom

City

stoke on trent

Street number

12 my street

Post Code

*** ***

Email

my email

Phone number

my phone number

Company Name

my company name

Comments

hello world

 

any problems let me Know good luck

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.