I don't have a ton of php experience but I am trying to have math problem echoed in the same browswer screen upon submit. Problem is when I submit nothing appears it just looks like i refreshed the page. I've tried moving the php coding into a seperate .php file so the form can call it. the same thing happens though. Do I need to be connected to Wamp so php can work? I'm not calling mysql or anything.

Recommended Answers

All 14 Replies

Member Avatar for nevvermind

The PHP file must be in the root folder ("C:\Program Files\wamp\www\" maybe?) and WAMP (Apache server, to be exact) must be on. Then run it with "http://localhost/math_file.php" in your browser.

If this doesn't work, paste your code here within [.code][./code] tags. It might have something to do with your source code.

please paste your code here :)

if you're using wamp server just enable display errors in php settings in order for you to be prompted with an error message, so as for you to determine the error.

pricing.htm

<div id="para">

<form method="post" action="pricing.php">

<textarea name="pages" value="" rows="1" cols="5"/>
</textarea>

Pictures<input type="radio" name="pictures" value="50">
<input type="radio" name="pictures" value="25" checked>
<input type="radio" name="pictures" value="0"><br>

Literature<input type="radio" name="literatures" value="100">
<input type="radio" name="literatures" value="50" checked>
<input type="radio" name="literatures" value="0"><br>
<br>


Pictures<input type="checkbox" name="picture value="50" ><br>
Page<input type="checkbox" name="literature" value="50" ><br>
Contact Form<input type="checkbox" name="contact" value="100" ><br>

<input type="submit" name="go" value="Calculate" />
</form>

</div>

pricing.php

<html>
<body>

 
<?php

$pages=$_REQUEST['pages'];
$pictures=$_REQUEST['pictures'];
$literatures=$_REQUEST['literatures'];
$picture=$_REQUEST['picture'];
$literature=$_REQUEST['literature'];
$contact=$_REQUEST['contact'];
$total=($pages*$pictures)+($pages*$picture)+($pages*$literatures)+
             ($pages*$literature)+$contact;

echo $total;
?>

</body>

</html>

I hasn't worked at all I even tried to echo $pages and it still doesn't work.

weird but it worked well with me... try changing $_REQUEST to $_POST

yep, try to use $_POST instead of $_REQUEST

Yes, I also agree with britoniah and flamer here. Hope posting $_POST can solve your problem immediately. Please try this and let us know what happened.

pricing.htm

<div id="para">

<form method="post" action="pricing.php">

<textarea name="pages" value="" rows="1" cols="5"/>
</textarea>

Pictures<input type="radio" name="pictures" value="50">
<input type="radio" name="pictures" value="25" checked>
<input type="radio" name="pictures" value="0"><br>

Literature<input type="radio" name="literatures" value="100">
<input type="radio" name="literatures" value="50" checked>
<input type="radio" name="literatures" value="0"><br>
<br>


Pictures<input type="checkbox" name="picture value="50" ><br>
Page<input type="checkbox" name="literature" value="50" ><br>
Contact Form<input type="checkbox" name="contact" value="100" ><br>

<input type="submit" name="go" value="Calculate" />
</form>

</div>

pricing.php

<html>
<body>

 
<?php

$pages=$_REQUEST['pages'];
$pictures=$_REQUEST['pictures'];
$literatures=$_REQUEST['literatures'];
$picture=$_REQUEST['picture'];
$literature=$_REQUEST['literature'];
$contact=$_REQUEST['contact'];
$total=($pages*$pictures)+($pages*$picture)+($pages*$literatures)+
             ($pages*$literature)+$contact;

echo $total;
?>

</body>

</html>

I hasn't worked at all I even tried to echo $pages and it still doesn't work.

It si good to RTM,
that being said it is not recommended to use request as it will pick contents of $_POST, $_GET, $_COOKIE. So be explicit to avoid problems. So just use $_POST/GET
Post being recommended! See Manual

It si good to RTM,
that being said it is not recommended to use request as it will pick contents of $_POST, $_GET, $_COOKIE. So be explicit to avoid problems. So just use $_POST/GET
Post being recommended! See Manual

That's a good point there. Thanks for the further explanation :)

could it be a problem with WAMP? I recently got rid of a site i built in there. Did I delete something i shouldn't have? if so how do i fix it? uninstall and reinstall?

I dont know what else it could be

wait, its not the WAMP maybe, (or if you still have doubts why don't you reinstall it?)
did you tried changing $_REQUEST to $_POST??

If you want to know if it is server issue or not try to make PHP file and access it on Url and in the PHP file put just the simple code below

<?php phpinfo();?>

It was wamp. I had deleted some of the files that were in there. I uninstalled and reinstalled the entire wamp program and php worked when i tested it in there. Thanks everybody for your help!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.