Jump to content

PHP form


rbvinc

Recommended Posts

I am trying to do the following, instead results,

I am getting blank screen.

Can somebody please advise me.

I have two files below, form-calc.php, calculate2.php

Thanks,

 

 

/// form-calc.php,

<HTML>

<HEAD>

<TITLE>Calculation Form</TITLE>

</HEAD>

<BODY>

<FORM METHOD="post" ACTION="calculate2.php">

<P>Value 1: <INPUT TYPE="text" NAME="val1" SIZE=10></P>

<P>Value 2: <INPUT TYPE="text" NAME="val2" SIZE=10></P>

<P>Calculation:<br>

<INPUT TYPE="radio" NAME="calc" VALUE="add"> add<br>

<INPUT TYPE="radio" NAME="calc" VALUE="subtract"> subtract<br>

<INPUT TYPE="radio" NAME="calc" VALUE="multiply"> multiply<br>

<INPUT TYPE="radio" NAME="calc" VALUE="divide"> divide</P>

<P><INPUT TYPE="submit" NAME="submit" VALUE="Calculate"></P>

</FORM>

</BODY>

</HTML>

 

// filetwo - calculate2.php

 

<?php

 

if (($_POST[val1] == "") || ($_POST[val2] == "") || ($_POST[calc] == "")) {

header("Location: calculate_form.html");

exit;

}

 

if ($_POST[calc] == "add") {

 

$result = $_POST[val1] + $_POST[val2];

 

} else if ($_POST[calc ] == "subtract"){

 

$result = $_POST[val1] - $_POST[val2];

 

} else if ($_POST[calc ] == "multiply"){

 

$result = $_POST[val1] * $_POST[val2];

 

} else if ($_POST[calc ] == "divide"){

 

$result = $_POST[val1] / $_POST[val2];

 

}

 

?>

 

<HTML>

<HEAD>

<TITLE>Calculation Result</TITLE>

</HEAD>

<BODY>

 

<P>The result of the calculation is: <? echo $result; ?></p>

 

</BODY>

</HTML>

 

 

Link to comment
https://forums.phpfreaks.com/topic/59992-php-form/
Share on other sites

Continuing on previous reply,

I tried northwind access database, it works fine with php (windows 2000/access 2000/php),

I tried <?php phpinfo() ?>, this works fine.

Only the above email problem,

and mysql connection. I cannot connect thru php, but

I can see dbs, tables, thru 'navicat' mysql editor.

 

Link to comment
https://forums.phpfreaks.com/topic/59992-php-form/#findComment-298416
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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