Jump to content
Larry Ullman's Book Forums

Chapter 11 - Sanitizing Functions And Valid Email Formats

Recommended Posts

Page 460 - step 11, last paragraph:


...after running it through sanitizing functions to make it safe...

..after confirming that it's a syntactically valid email address.


I think I can do the latter, with the help of Regular Expressions, but I need a hand (no, I don't need the code written for me, I prefer to write it myself) with how to sanitize comments. I know I would need to remove HTML tags but what else is there?


I've been looking at W3Schools (yes, I'm that desparate! I don't have a book that contains cogent information on how to code/program in PHP) as well as other website tutorials. They're all incomplete in some form or other but they at least give me some idea how to format a PHP script/program.


Side Note: I'm extremely dismayed at the _lack_ of information on how to connect a PHP script/program to a Microsoft SQL Server Express database. Yes Yes, PHP and MySQL are ".join()"ed at the hip but with the ample availability of SQL Server Express, you'd think someone would've picked up on this and wrote some sample PHP code for Microsoft's platform...regardless of how they feel about the company and leader(s). My intention is not to start a "m$ war" so if you intend on responding, please do so with proof/links to back up your defense.

Link to post
Share on other sites
  • 4 months later...

Hi Larry

After running the example provided on page 460 section 11 I get the following error:

Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\html\xperiment\raw-js\modern-js\ch-11\resources\contact.php on line 2


Here is my Code:

<?php # Script 13.3 - login.php
mail('jack.ui.maynard@gmail.com', 'Contact form Submission', $body, $from);

?>The message has been sent.


And here is my php.ini file : smtp section

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = you@yourdomain

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path =

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =

; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = On

; Log all mail() calls including the full path of the script, line #, to address and headers
;mail.log =


CAn you please advise what I have to do.


Thank you.

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.
Note: Your post will require moderator approval before it will be visible.

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.

  • Create New...