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
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
Share on other sites

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.