Jump to content
SimonB

coding php send form

Recommended Posts

I have a small problem (literally) with my php send form. It works perfectly well, but the acknowledgement (and error) page appears too small to read on a cellphone. On larger screens it is OK. Ideally I would like the page to appear max width 450, height 600 (same as the contact form) or device width on smaller screens

The website is here, https://tourtheloire.com and my php coding is attached.  I assume I am making a simple error, but php is a mystery to me. Thanks in advance for any help
 

html_form_send.php

Edited by SimonB

Share this post


Link to post
Share on other sites

It may be that :) . On a desktop or laptop it's fine, but on a mobile device (mine is an android phone) the text on the acknowledgement page doesnt resize, so the text is minute. Top  screenshot is the contact form (good) bottom screenshot is what I get when I press send. It functions fine, but isn;t actually readable.

 

contact.png

acknowledge.png

Edited by SimonB

Share this post


Link to post
Share on other sites

Use CSS, set the font size using relative units like points instead of absolute units like pixels.

Share this post


Link to post
Share on other sites

Your PHP code should produce a valid HTML document, so you'd use the same principles that you do with any other HTML document.

Share this post


Link to post
Share on other sites

Not sure I understand - I have tried entering a font size (16pt) just about everywhere on the php form to no effect

for instance, where do I  insert font size in this phrase

function died($error) {
        // your error code can go here
        echo "We are very sorry, but there were error(s) found with the form you submitted. ";
        echo "These errors appear below.<br /><br />";
        echo $error."<br /><br />";
        echo "Please go back and fix these errors.<br />

<br />";
        die();

 

I have tried it as a head, and at the top of the document, and also before each line of text (and different font sizes) to no discernable effect

 

Edited by SimonB

Share this post


Link to post
Share on other sites

You need to echo all of the HTML tags, right now the text you see there is the entire document.  So before you output those messages, you want to print the doctype, html tag, head tag maybe with a style block, body tag, maybe you want to wrap the messages in a div or span and put a class on it, etc.  Just like you're writing regular HTML.  You just use PHP to echo the HTML instead of just writing it in the file.  You can also close the PHP tag and just start writing HTML like at the bottom of the code.

Share this post


Link to post
Share on other sites

what is " echo all of the HTML tags, "

 

The code I have is cut and pasted from a "this is how to do a contact form" I don't know what any of it does.

Share this post


Link to post
Share on other sites

The echo statement is how you send output to the web browser in PHP.  It's not the only way, but it's common.  Look at the died function, it uses echo to send messages to the browser.  You use the same method to send HTML, it's all output that goes to the browser.  You can also end the PHP code, output whatever you want, and then start PHP again.  e.g.:

php code here
?>

<!-- send output -->
<!doctype>
<html>
  <head>
    ...
  </head>
  <body>
    
<?php 
// start PHP again 

Anything outside of PHP tags is considered to be output that is just sent to the browser.

Share this post


Link to post
Share on other sites
On 3/14/2019 at 10:20 AM, SimonB said:

what is " echo all of the HTML tags, "

 

The code I have is cut and pasted from a "this is how to do a contact form" I don't know what any of it does.

Heres example below, if you didn't understand the above one.

<html>
<head>
<style>
h2 { font-size:28px; }
p { font-size:20px; }
</style>
</head>
<body>
<?php
//Comment
//So you echo out HTML code with tags (example below)
echo "<h2>This is heading 2</h2>"; //Heading 2 --- h2 tags
echo "<p>Text inside paragraph</p>"; //Paragraph tags
echo "No HTML whatsoever"; //plain text
?>
</body>
</html>

 

 

Edited by Mudsaf

Share this post


Link to post
Share on other sites
On 3/14/2019 at 12:15 AM, SimonB said:

Not sure I understand - I have tried entering a font size (16pt) just about everywhere on the php form to no effect

for instance, where do I  insert font size in this phrase

function died($error) {
        // your error code can go here
        echo "We are very sorry, but there were error(s) found with the form you submitted. ";
        echo "These errors appear below.<br /><br />";
        echo $error."<br /><br />";
        echo "Please go back and fix these errors.<br />

<br />";
        die();

 

I have tried it as a head, and at the top of the document, and also before each line of text (and different font sizes) to no discernable effect

 

And here you are using HTML <br> tags.

More about making styles @https://www.w3schools.com/css/default.asp

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...