Jump to content

Recommended Posts

I have the following code, first off I should mention that I am trying to run it from the wamp server

(localhost) because I only need to demo my form, not put it on a web server.  So the first question is, can I do that.  Second when I click send on the form, I get the dreaded "The page could not be dislpayed".  WHY?

 

The HTML Part:

<html>
<head>
<style type ="text/css">
div#wrap{

margin:0 auto;
width:400px;
</style>
<body>


<div id="wrap">
<FORM METHOD = "post" action="http://localhost/sendmail.php">

First Name:
<input  type ="text" name="firstname"/>
&nbsp
<br/>
Last Name:
<input type ="text" name="lastname"/>
<br/>
<br/><dd/>
Comments orSuggestions:
<br/><dd/>
<textarea name="comment" rows="10" cols="50"></textarea>
</textarea>
<br/>
&nbsp &nbsp &nbsp &nbsp &nbsp
<input type = "submit" value="send">
<input type = "reset"  value="clear">
</form>
</div>
</body>
</head>
</html>

 

The PHP part

<?php
$first = $_REQUEST['firstname'];
$last = $_REQUEST['lastname'];
$comment = $_REQUEST['comment'];

mail("code.bro@verizon.net", "Comments/Suggestions",
    "From: $first,$last", "Comment:$comment");

header("Location:E:/Senior Project/cater.html");
?> 

 

 

Link to comment
https://forums.phpfreaks.com/topic/99534-question-about-code-and-wamp-server/
Share on other sites

when using forms you don't need to use the entire url for the submital. just reference the file from where the current script is running. If sendmail.php is in the same folder as the current running script use. also is this all on the same page???

 

<FORM METHOD = "post" action="sendmail.php" />

 

Ray

 

That is the problem, the sendmail.php is not in the same folder.  Because I am trying to run it from the wamp server (localhost) it has to go into a special location which is C:\wamp\www.  If you do not put the .php file in this location, it will not run.

No, that is the point I am trying to make.  There is no web server.  The site contents are on E:\

All I am trying to do is demo the form to show that it works.  It will NEVER be put onto a web server.

The point of the wamp is to run php on your localhost.  But I seem to be having a problem doing that.

Someone in another forum mentioned having to set the wamp ini setting, but I have no idea what they were talking about

easiest thing to do is move the project to the www folder. Save yourself a lot of headaches.

 

Have you checked to make sure php is running fine, you can also change localhost to the ip address of the box instead. http://xxx.xxx.xxx.xxx/sendmail.php

Well first off you have nothing that is outputting on the screen, second your header location is pointing to a place outside of WAMP. Your web server will only work inside www.

 

if you want put a check in

 

<?php
$first = $_REQUEST['firstname'];
$last = $_REQUEST['lastname'];
$comment = $_REQUEST['comment'];

if(!mail("code.bro@verizon.net", "Comments/Suggestions","From: $first,$last", "Comment:$comment")){
echo "Mail could not be sent";
} else {
header("Location:E:/Senior Project/cater.html");
}
?>

 

You sould also change E:/Senior Project/cater.html to a page within the web server (www)

 

Ray

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.