Boxerman Posted July 26, 2008 Share Posted July 26, 2008 i need to make one of these, but dont know how? Quote Link to comment https://forums.phpfreaks.com/topic/116730-need-help-fixing-errors/ Share on other sites More sharing options...
mattal999 Posted July 26, 2008 Share Posted July 26, 2008 read up on this: http://uk3.php.net/manual/en/function.mail.php and use this to get page location: <?php $location = $_SERVER["PHP_SELF"]; ?> Quote Link to comment https://forums.phpfreaks.com/topic/116730-need-help-fixing-errors/#findComment-600217 Share on other sites More sharing options...
Boxerman Posted July 26, 2008 Author Share Posted July 26, 2008 Ok so how do i put the code together? Quote Link to comment https://forums.phpfreaks.com/topic/116730-need-help-fixing-errors/#findComment-600230 Share on other sites More sharing options...
Boxerman Posted July 26, 2008 Author Share Posted July 26, 2008 Any pm me the code or anything? Quote Link to comment https://forums.phpfreaks.com/topic/116730-need-help-fixing-errors/#findComment-600275 Share on other sites More sharing options...
DarkWater Posted July 26, 2008 Share Posted July 26, 2008 Well, we're not going to code it for you. You'd use, as mattal999 suggested, $_SERVER['PHP_SELF'] to get the current page, and then mailing is easy... Quote Link to comment https://forums.phpfreaks.com/topic/116730-need-help-fixing-errors/#findComment-600280 Share on other sites More sharing options...
.josh Posted July 26, 2008 Share Posted July 26, 2008 #1 has been shown to you, we have no idea how you have your code setup so we can't tell you what to use for #2, and you were pointed in the right direction for #3. We don't write code for you. We help you fix your own code. If you wish for someone to write it for you, post in the freelance section (read the stickies first). Quote Link to comment https://forums.phpfreaks.com/topic/116730-need-help-fixing-errors/#findComment-600281 Share on other sites More sharing options...
Boxerman Posted July 26, 2008 Author Share Posted July 26, 2008 Ok thanks guys, would it be like this, <?php // The message $message = "$location = $_SERVER["PHP_SELF"];"; // In case any of our lines are larger than 70 characters, we should use wordwrap() $message = wordwrap($message, 70); // Send mail('[email protected]', 'My Subject', $message); ?> Quote Link to comment https://forums.phpfreaks.com/topic/116730-need-help-fixing-errors/#findComment-600291 Share on other sites More sharing options...
DarkWater Posted July 26, 2008 Share Posted July 26, 2008 No. The $message variable is wrong. Try: $message = sprintf('Location: %s', $_SERVER['PHP_SELF']); Quote Link to comment https://forums.phpfreaks.com/topic/116730-need-help-fixing-errors/#findComment-600294 Share on other sites More sharing options...
Boxerman Posted July 26, 2008 Author Share Posted July 26, 2008 Ok, explain that please? also, how do i add checkboxs in php? Quote Link to comment https://forums.phpfreaks.com/topic/116730-need-help-fixing-errors/#findComment-600297 Share on other sites More sharing options...
DarkWater Posted July 26, 2008 Share Posted July 26, 2008 Just use that as the message variable if you want. It's neater. But anyway...checkboxes are HTML, not PHP. Quote Link to comment https://forums.phpfreaks.com/topic/116730-need-help-fixing-errors/#findComment-600299 Share on other sites More sharing options...
MFHJoe Posted July 26, 2008 Share Posted July 26, 2008 Using the line: $message = "$location = $_SERVER["PHP_SELF"];"; Would have caused an error anyway (the double quotes would have confused PHP). DarkWater's code just makes it work like we presume you want it to. If for whatever reason you have taken a dislike to DarkWater's code, use: $message = 'location = '.$_SERVER["PHP_SELF"]; Quote Link to comment https://forums.phpfreaks.com/topic/116730-need-help-fixing-errors/#findComment-600302 Share on other sites More sharing options...
Boxerman Posted July 26, 2008 Author Share Posted July 26, 2008 ok, so is there a way i can create a form, link it to php and when a user clicks submit sends it? Quote Link to comment https://forums.phpfreaks.com/topic/116730-need-help-fixing-errors/#findComment-600307 Share on other sites More sharing options...
wildteen88 Posted July 26, 2008 Share Posted July 26, 2008 Yes, You create the form in HTML first (google html forms). When the form is submitted to a PHP script, the data sent will be in the $_POST or $_GET superglobal (depends on your form submit method). Quote Link to comment https://forums.phpfreaks.com/topic/116730-need-help-fixing-errors/#findComment-600312 Share on other sites More sharing options...
Boxerman Posted July 26, 2008 Author Share Posted July 26, 2008 <html> <body> <?php if (isset($_REQUEST['email'])) //if "email" is filled out, send email { //send email $email = $_REQUEST['email'] ; $subject = $_REQUEST['subject'] ; $message = $_REQUEST['message'] ; mail("[email protected]", "Subject: $subject", $message, "From: $email" ); echo "Thank you for using our mail form"; } else //if "email" is not filled out, display the form { echo "<form method='post' action='mailform.php'> Email: <input name='email' type='text' /><br /> Subject: <input name='subject' type='text' /><br /> Message:<br /> <textarea name='message' rows='15' cols='40'> </textarea><br /> <input type='submit' /> </form>"; } ?> </body> </html> would that be around the lines? Quote Link to comment https://forums.phpfreaks.com/topic/116730-need-help-fixing-errors/#findComment-600313 Share on other sites More sharing options...
MFHJoe Posted July 26, 2008 Share Posted July 26, 2008 Change the line echo "<form method='post' action='mailform.php'> to echo "<form method='post' action='".$_SERVER['PHP_SELF']."'> And then yeah, that should be about right mate. Change $_REQUEST to $_POST as well. It's just better practise seeing as you're only looking for the $_POST variable ($_REQUEST contains $_POST, $_GET and $_COOKIE). Quote Link to comment https://forums.phpfreaks.com/topic/116730-need-help-fixing-errors/#findComment-600322 Share on other sites More sharing options...
Boxerman Posted July 26, 2008 Author Share Posted July 26, 2008 Thanks! so what do i do to add check boxs? Quote Link to comment https://forums.phpfreaks.com/topic/116730-need-help-fixing-errors/#findComment-600327 Share on other sites More sharing options...
MFHJoe Posted July 26, 2008 Share Posted July 26, 2008 <input type="checkbox" name="check" /> When someone checks it, it's value will be on ($_POST['check'] == 'on'), if someone doesn't check it, $_POST['check'] doesn't exist (you can check if it exists using isset($_POST['check']). Quote Link to comment https://forums.phpfreaks.com/topic/116730-need-help-fixing-errors/#findComment-600329 Share on other sites More sharing options...
Boxerman Posted July 26, 2008 Author Share Posted July 26, 2008 ahh im confused Quote Link to comment https://forums.phpfreaks.com/topic/116730-need-help-fixing-errors/#findComment-600337 Share on other sites More sharing options...
MFHJoe Posted July 26, 2008 Share Posted July 26, 2008 <input type="checkbox" name="check" /> Is the HTML for making a checkbox. Put this in your form. To see if someone has checked it or not, in your form processing section, use: if(isset($_POST['check'])) { // The checkbox has been checked. Do something here. } So altogether, your code may look something like this: <?php if (isset($_POST['email'])) //if "email" is filled out, send email { //send email $email = $_POST['email'] ; $subject = $_POST['subject'] ; $message = $_POST['message'] ; if(isset($_POST['check'])) { $message .= ' The user checked the checkbox.'; } mail("[email protected]", "Subject: $subject", $message, "From: $email" ); echo "Thank you for using our mail form"; } else //if "email" is not filled out, display the form { echo "<form method='post' action='".$_SERVER['PHP_SELF']."'> Email: <input name='email' type='text' /><br /> Subject: <input name='subject' type='text' /><br /> Message:<br /> <textarea name='message' rows='15' cols='40'> </textarea><br /> Checkbox: <input type="checkbox" name="check" /><br /> <input type='submit' /> </form>"; } ?> </body> </html> The bit inside the if statement uses .= to add a sentence to the end of $message. Quote Link to comment https://forums.phpfreaks.com/topic/116730-need-help-fixing-errors/#findComment-600339 Share on other sites More sharing options...
Boxerman Posted July 26, 2008 Author Share Posted July 26, 2008 ok sorta getting it now, so how do i design it like the picture i made? Quote Link to comment https://forums.phpfreaks.com/topic/116730-need-help-fixing-errors/#findComment-600344 Share on other sites More sharing options...
wildteen88 Posted July 26, 2008 Share Posted July 26, 2008 Again this is down to HTML (and CSS) not PHP. To apply a background color to an HTML element on a page with CSS do: <style type="text/css"> /* CSS syntax html_tag_name { attribute: value }*/ /* REAL EXAMPLE */ form { background-color: #FFCC00; } The above CSS will give your form an orange background color. There are many CSS tutorials onlines, have a look at the tutorials over at w3school.com Quote Link to comment https://forums.phpfreaks.com/topic/116730-need-help-fixing-errors/#findComment-600351 Share on other sites More sharing options...
Boxerman Posted July 26, 2008 Author Share Posted July 26, 2008 ahh css yes ok, what about having it as a pop up? Quote Link to comment https://forums.phpfreaks.com/topic/116730-need-help-fixing-errors/#findComment-600369 Share on other sites More sharing options...
MFHJoe Posted July 26, 2008 Share Posted July 26, 2008 [url=http://www.accessify.com/tools-and-wizards/accessibility-tools/pop-up-window-generator/default.php[/url]JavaScript Popup Window Generator . Just use a separate page. You're still going to need to use CSS though. Quote Link to comment https://forums.phpfreaks.com/topic/116730-need-help-fixing-errors/#findComment-600372 Share on other sites More sharing options...
Boxerman Posted July 26, 2008 Author Share Posted July 26, 2008 ok, but when having a pop up thingy, instead of the location part do i put referer? Quote Link to comment https://forums.phpfreaks.com/topic/116730-need-help-fixing-errors/#findComment-600389 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.