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.

Styling a php form

Featured Replies

Hey guys,

 

I have a form that is working, now all I am trying to do is make to emailed form look a little more attractive.

 

I am trying to put the contents into a table as follows.

 

 <tr>
   <td width="100">Name</td>
   <td width="200">
   <?php include(" . $_POST['field_1'] . "); ?></td>
 </tr>
 <tr>

 

Can somebody tell me why this doesnt work and suggest an alternative?

 

That would be great, Thanks!

Try...

 <tr>
   <td width="100">Name</td>
   <td width="200">
   <input type="text" name="field_1" value="<?php echo $_POST['field_1']; ?>" /></td>
 </tr>
 <tr>

 

* note, this is just to get your php working.

Edited by Mollart

Don't use tables for styling use CSS. Tables are for tabular data.

  • Author

This is the original code and i am just trying to put the

" . $_POST['field_1'] . "

parts of the code into the table.

 

Can i modify the below in anyway to include styling?

 

<?php

$where_form_is="h.t.t.p://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));

mail("email@address.com","WEBSITE QUERY","Form data:

Name:   	" . $_POST['field_1'] . " 
Email: 		" . $_POST['field_2'] . " 
Company: 	" . $_POST['field_3'] . " 
Telephone: 	" . $_POST['field_4'] . " 
Message: 	" . $_POST['field_5'] . " 

");

include("confirm.php");

?>

Think you both misread the thread, he already has the form working and he wants to style the email that is recieved so it looks a bit nicer, if I have read it right that is?

 

So tables would be the way to go for this, but I'm not sure how to do it.

YOu need to change your headers and send a html email, as opposed to plaion text.

 

BTW: using tables to style a foprm is considorted bad practice as it's not semantic.

 

But he only wants it to be styled as an email in the email clien? Not in the actual form? Or am I completely wrong and missing the point?

  • Author

Thats correct, its only the email I would like to style. The form is CSS styled.

 

What part of this code needs to be edited without messing up the processing part i.e. sending the email?

Yep you've missed the point :)

 

He wants to stryle the email. To style the email you'll need to set your headers to html as opposed the plain text :)

 

Ahh, I wasn't questioning your first point about changing the headers to to html. It was about saying using tables to style a form is considered bad practice. But if you're sending it as an email, tables are the way to go?

 

Is this what you would change the header too?

 

header('Content-Type: text/html',true);

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.