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.

manx

Members
  • Joined

  • Last visited

  1. @ thanks for the advice and yes this certainly answers my question regarding server-side validation and the filter_var is the route I need to take. Just checking for "blank values" and echoing any errors, is not as helpful to me as actually checking that say, a validly formatted email address has been added into the field as opposed to just "something has been added into that field". @@NOCK thanks for the advice and yes I am a novice (does it show?!) - but what I was looking for was really some form of explanation of what I had done right and wrong and indeed what could be done or added to improve - so such as webdesigner93 - those were the kind of suggestions I was after. @@Lyndsey yes personally I have chosen to have all my html on one page (the contact form page) and run the php code separately within a .php page thereby keeping the two separate. I know others prefer to place the php on the same page as html..does it matter or just a personal preference?
  2.    manx reacted to a post in a topic: Need some help with simple PHP script!
  3. I have been teaching myself PHP for the last month and have come up with this script. I'm sure its not perfect but that's the point. I was really hoping for some folk on this forum who actually know more than I about php who can can look at my script and critique or make suggestions giving me indications of whether it needs tweaking. Telling me to watch some videos on youtube is quite unhelpful.
  4. What about adding validation to the php script itself? How would I do that please as this is an area I'm struggling with. I require the fields name, email, telephone and message to all be required.
  5. Okay nicely explained. So if this particular "hidden" field in not filled out (ie. not set) the stuff in squiggley brackets means "then send the form"?
  6. Hi Nock, thanks for the response. So the url field is hidden and intended for anti-spam. Basically any bot can fill this in but I don't want the form then emailed to me if this happens. Are you saying that my code for that was wrong and that your code if(!isset($_POST['url'])){ will ensure that if this field is ever filled in the form won't get sent?
  7. I am new to PHP (please be gentle!) and so getting my head around it. I have just created my contact form and the code looks like this <form action="/sendform.php" method="post"> <p>Your name: <input type="text" name="name"></p> <p>Your email: <input type="text" name="email"></p> <p>Your telephone: <input type="text" name="telephone"></p> <p class="nospam">Leave this empty: <input type="text" name="url"></p> <p><textarea name="message"></textarea></p> <p><input type="submit" value="Send"></p> </form> I have created a separate sendform.php file and the code within this looks as follows:- <?php if(isset($_POST['url']) && $_POST['url'] == ''){ $youremail = 'me@example.com'; $body = "This is the form that was just submitted: Name: $_POST[name] E-Mail: $_POST[email] Message: $_POST[message]"; if( $_POST['email'] && !preg_match( "/[\r\n]/", $_POST['email']) ) { $headers = "From: $_POST[email]"; } else { $headers = "From: $youremail"; } mail($youremail, 'Contact Form', $body, $headers ); } header('Location: http://www.example.com/thanks/'); ?> So the first line of code (if I have got this correct) I am tryint to tell the form not to send the form to me, if the url field is filled in [as this is intended as a hidden field]. Further down I added the [!preg_match] to help protect the script from email injection. I have heard this is the correct way to do this? Is this form okay as it stands? And in terms of validation, is there a simple piece of code I can add somewhere within this script to ensure that the user fills in all the required fields ie Name, Email, Telephone & Message? Thanks so much for any help and advice on this.. I have been researching for days!

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.