HW 2 – PHP calculator

for this assignment, I decided to create a form in which the user would tell about their day. Was their day good or bad? The user can also read about other people’s days.

Right now (end of the semester) I went back to this assignment to try and make the database connection work. I have a table in mysql database and I am able to manually add data into it. I also managed to get a database connection but when the form is filled out, no lines are added to the table.

This is my code, I would appreciate any help:

form.php

<?php
$id = $_POST [“id”];
$name = $_POST[“yourname”];
$date = $_POST[“date”];
$food = $_POST[“general”];
$howwasit= $_POST[“howwasit”];

?>
<html>
<head>
<title>HOW WAS YOUR DAY?</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
<style type=”text/css”>
.inputbtn {
font-family: “Trebuchet MS”, Arial, Helvetica, sans-serif;
font-size: 18px;
color: #FFF;
background-color: #000;
}
.title {
font-family: “Lucida Sans Unicode”, “Lucida Grande”, sans-serif;
}
</style>
</head>
<input id=”date” name=”date”readonly>
<script type=”text/javascript”>
document.getElementById(‘date’).value = Date();
</script>

<form name=”input” form action=”process.php” method=”post”>
<h1>We all have our days,<br/> HOW WAS YOUR DAY? </h1>
<body bgcolor=”#F5F9BC” centermargin=”100″ topmargin=”100″ marginwidth=”50″ marginheight=”50″>
<p><span class=”title”>Your Name</span>
<input type=”text” name=”yourname”><br/><br/>
<span class=”title”>In general </span><br/><input type=”radio” name=”general” value=”good”>
<span class=”title”>good
</span><br/><input type=”radio” name=”general” value=”bad”>
<span class=”title”>bad </span><br/><br/>

<span class=”title”>Let’s hear more about it! </span><br/>
<textarea name=”howwasit” cols=”50″ rows=”5″></textarea>
<br/>
<input type=”submit” class=”inputbtn” value=”Tell Us”>
</p>
<p>&nbsp;</p>
<p>
<input type=”reset” value=”Clear”>
</p>
<p>&nbsp;</p>
<p><br/>
<h1>Let’s see what other people’s day was like</h1><br/>
</p>

</form>
</body>
</html>

 

 

process.php

<?php
$id = $_POST [“id”];
$name = $_POST[“yourname”];
$date = $_POST[“date”];
$food = $_POST[“general”];
$howwasit= $_POST[“howwasit”];

?>
<html>
<head>
<title>HOW WAS YOUR DAY?</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
<style type=”text/css”>
.inputbtn {
font-family: “Trebuchet MS”, Arial, Helvetica, sans-serif;
font-size: 18px;
color: #FFF;
background-color: #000;
}
.title {
font-family: “Lucida Sans Unicode”, “Lucida Grande”, sans-serif;
}
</style>
</head>
<input id=”date” name=”date”readonly>
<script type=”text/javascript”>
document.getElementById(‘date’).value = Date();
</script>

<form name=”input” form action=”process.php” method=”post”>
<h1>We all have our days,<br/> HOW WAS YOUR DAY? </h1>
<body bgcolor=”#F5F9BC” centermargin=”100″ topmargin=”100″ marginwidth=”50″ marginheight=”50″>
<p><span class=”title”>Your Name</span>
<input type=”text” name=”yourname”><br/><br/>
<span class=”title”>In general </span><br/><input type=”radio” name=”general” value=”good”>
<span class=”title”>good
</span><br/><input type=”radio” name=”general” value=”bad”>
<span class=”title”>bad </span><br/><br/>

<span class=”title”>Let’s hear more about it! </span><br/>
<textarea name=”howwasit” cols=”50″ rows=”5″></textarea>
<br/>
<input type=”submit” class=”inputbtn” value=”Tell Us”>
</p>
<p>&nbsp;</p>
<p>
<input type=”reset” value=”Clear”>
</p>
<p>&nbsp;</p>
<p><br/>
<h1>Let’s see what other people’s day was like</h1><br/>
</p>

</form>
</body>
</html>

 

Leave a Comment.