Jump to content

blacksheep

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

blacksheep's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I want to have a link on a website that when you click it, it'll open up your email client (ie: Outlook) and have some message content. Is this even possible? I know that you can do a subject easily with something like: [code]mailto:email@domain.com?subject=subject line [/code] But how do I make it have some content? I'd do it in a php form, but we need the emails to be coming directly from the professors' email addresses for basic security and bookkeeping purposes in the department so I just wanted them to have a template to work with without having to ctrl+c/ctrl+v it. Thanks for any input! Jonathon
  2. [quote author=ksteuber link=topic=112686.msg457489#msg457489 date=1161796290] First of all. Large parts of this code flat out don't make sense to me. Lemme see if I can fix this up a little... [code] // $subject  = "Facilities Request $type"; This line should be after $type is defined // ** Actually, it never had a problem with it, but I see your logic //Change this to html to make things easier later //This too //I don't see any good reason to use a different variable here // ** Surprisingly, all that error nonsense worked perfectly. I didn't see a reason for a second variable either, but it never recognized it as false. It refused to enter the final else statement and always took error as true. As soon as I made it a second variable and had it written that way, it recognized it. haha. There's probably something messed up elsewhere, but this works :D //Change this line to conform to change in variables above... //I'm not sure that mail() returns anything at all, and if it does, you don't use it anyways. // ** What do you mean mail() doesn't do anything? I thought it was the function that sent the form response to my email? //Don't print $errormsg here. Print it IN the html // ** That would clean it up a bit, but now I'm afraid it'll change how it displays it and I won't be able to fix it, haha //You already know what $error and $error2 are gonna equal, why globalize them here? And why change $error to false? // ** I was changing error to false incase it decided to remember it as true when it went through the next time. I think it was like that mostly because I was trying to find the bug with it not going through the else statement. Ideally, it should reset to false or stay true in the if statement anyways - so I see your point. //OK, I'm pretty sure you can't do this, because I think you only want the page to show this stuff if is executes error_out, and if you type it outside of the </?php, it'll show this one way or the other. This is // ** Actually, the function only appears in the if, elseif, so it'll only display the form again when you error. The first form display is another php file that posts to this one. lol. It's mostly because the error checking was a complete afterthought :D [/code] I haven't tried this yet, there may still be bugs, but was this what you were trying to do? [/quote] Thanks a bunch for the tips on the poor code, but somehow, someway, it all worked as it was perfectly well.  ??? haha. [quote author=gmwebs link=topic=112686.msg457478#msg457478 date=1161795343] [code] <textarea name="request" rows="10" cols="43"><?php echo $_POST['request'] ?></textarea> [/code] [/quote] Wow, that was surprisingly easy! Damn. lol. Thanks! [quote author=HuggieBear link=topic=112686.msg457530#msg457530 date=1161799835] Try replacing just this bit of code: [code] <select name="type"> <option> Please Select Type of Request <option> - Maintenance <option> - Telecommunications <option> - Work Order <option> - Other </select> [/code] With this: [code] <select name="type"> <?php $dropdown = array("Please Select Type of Request", "Maintenance", "Telecommunications", "Work Order", "Other"); foreach ($dropdown as $option){    if ($option == $_POST['type']){       echo "<option value=\"$option\" selected=\"selected\"> - $option</option>\n";    }    else {       echo "<option value=\"$option\"> - $option</option>\n";    } } ?> </select> [/code] You should be able to just swap it straight out. Regards Huggie [/quote] Thank you so much! That code works great - I just wish I knew how it worked completely. If you have the time, could you explain it a little (mostly the if statement)?  :) Thanks again to everyone! This was a really quick and knowledgable response!
  3. I'd consider this my first real php experience as I've only used include() before now, lol, but I'm having a hard time with some form validation. It's easy enough to check for problems and error it out, but I want to have the user still have all their inputted information displayed in the form (even the errored stuff). I've been looking around online for a couple days on this and figured most of it out but I can't get the damn drop-down menu or the textarea to "save". Pardon the ghetto code  :-[ The error stuff wasn't being recognized and I finally messed around until it worked and so I don't want to clean it up and break it. ;D [code] <?php /* define blanks */ $to      = "my email"; $subject  = "Facilities Request $type"; $email    = $_POST['email']; $name    = $_POST['name']; $phone    = $_POST['phone']; $building = $_POST['building']; $room    = $_POST['room']; $request  = $_POST['request']; $type    = $_POST['type']; $message  = ""; /* Form Validation */ if ($email == "" || $name == "" || $phone == "" || $building == "" || $room == "" || $request == "" || $type == "Please Select Type of Request") { $errormsg = "Error: One or more field was left blank."; $error = true; error_out(); } elseif (!eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,4})$", $email)) { $errormsg = "Error: Invalid email address."; $error = true; error_out(); } else { $error2 = 1; } /* define message content */ $message .= "Request Type: $type <br><br>"; $message .= "From: $name <br>"; $message .= "Email Address: $email <br>"; $message .= "Phone Number: $phone <br><br>"; $message .= "Building: $building <br>"; $message .= "Room: $room <br><br>"; $message .= "Message:\n $request\n"; /* clearly define headers */ $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n"; $headers .= "To: name <my email>\n"; $headers .= "From: name <do-not-reply email>\n"; if($error2 == 1) { $sent = mail($to, $subject, $message, $headers); print "<p align=center><br>Thank you. Your request was sent successfully and will be processed soon.</p>"; } else { print "<font color=red> $errormsg </font> <br><br>"; } function error_out() { global $errormsg; global $email; global $name; global $phone; global $building; global $room; global $request; global $message; global $type; global $error2; global $error; $error = false; ?> <!-- contact_m.php --> <div align="center"> <p class="MAEtitleText"> <font color="#000066" size=+2><strong>Maintenance Request Form</strong></font><br> All Fields Required </p> <form method="post" action="sendform_m.php"> <table width=300 border=0> <tr> <td width="40%"> Name: </td> <td> <input name="name" type="text" size="32" value="<?php echo $name ?>"> </td> </tr> <tr> <td> Email: </td> <td> <input name="email" type="text" size="32" value="<?php echo $email ?>"> </td> </tr> <tr> <td> Phone Number: </td> <td> <input name="phone" type="text" size="32" value="<?php echo $phone ?>"> </td> </tr> <tr> <td> </td> <td align=right> Building: <input name="building" type="text" size="7" value="<?php echo $building ?>">&nbsp; Rm: <input name="room" type="text" size="5" value="<?php echo $room ?>"> </td> </tr> <tr> <td><br></td> </tr> <tr> <td colspan=2> <select name="type"> <option> Please Select Type of Request <option> - Maintenance <option> - Telecommunications <option> - Work Order <option> - Other </select> </td> </tr> <tr> <td> Request: </td> <td> </td> </tr> <tr> <td colspan=2> <textarea name="request" rows="10" cols="43" value="<?php echo $_POST['request'] ?>"></textarea> </td> </tr> <tr> <td> <input type="submit" value="Submit"> </td> <td align=right> <input type="reset" value="Reset"> </td> </tr> </form> </div> <?php } ?> [/code] I truly appreciate any help.  :)
×
×
  • 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.