Jump to content

Quotes in Form Fields...


ScaryHouse

Recommended Posts

Hi Everyone,

I am really, really new to PHP so, I'll need baby steps and a lot of hand holding to get through this.

 

Where I work I get Service Requests from grade school teachers for help with their classroom computers. When I started my job, it was a mess of scraps of paper from principals stuck in my mail box, unintelligible emails, and phone calls. I desperately needed to get a way for teachers to contact me that would help me organize my work. I wanted it all to come in email, and I needed some basic info to be consistantly present.

 

I put a form together so I could get consistent information from them without having to go back and ask stuff like, "What building are you in?" "What's your room number?" etc.

 

I've cut and pasted a lot of bits and pieces from different tutorials to build the form to email script I'm using now. I'm amazed at how well it works, considering I didn't really learn anything during my frantic attempt to build it.

 

 

The problem is with special characters.

I really don't know what I'm doing, so I don't know how to fix it.

 

In the Request part of the form, a teacher or principal with write something like this:

 

Can someone check into the specs for the program "Writing with Symbols" by Mayer Johnson.

 

But, in my email, i'll get something like this:

 

Can someone check into the specs for the program "Writing with Symbols" by Mayer Johnson.

 

I can get by with that, and I have, but sometimes I need to forward info to other people and I'd like it to look better.

 

Everyone, thank you in advance for your help.

Sincerely,

Dan Gildea

ScaryHouse

 

Here is my Frankenstein's monster of a Form to Email script:

 

<?php

$code = check_input($_POST['code'],"Please go BACK and choose your building!");

$room = check_input($_POST['room'],"Please go BACK and enter your room #!");

$name = check_input($_POST['name'],"Please go BACK and enter your name!");

$email = check_input($_POST['email']);

if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email))

{

    die("Please go BACK and enter a valid email address!");

}

$request = check_input($_POST['request'],"Please go BACK and describe your problem!");

?>

 

 

 

<?php

$header = "From: $email\r\nReply-To: $email\r\n";

$recipient = "cservice@kidsroe.org";

$subject  = "$code-$room $name";

$message  = "$code-$room $name

 

$request

";

 

mail($recipient, $subject, $message, $header);

?>

 

<html>

<body>

Your message was successfully sent!<br />

You wlll be contacted soon.

</body>

</html>

 

 

 

<?php

function check_input($data, $empty='')

{

    $data = trim($data);

    $data = stripslashes($data);

    $data = htmlspecialchars($data);

    if ($empty && strlen($data) == 0)

    {

        die($empty);

    }

    return $data;

}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.