How can I print the Database table in PHP please ?
here I have form for name and email, also I have php code that allow user to add his name and email to my database, all I need to print my final database when the user click on submit.
<form action="" method="post">
<label>Name :</label>
<input type="text" name="name" required="required"
placeholder="Please Enter Name"/><br /><br />
<label>Email :</label>
<input type="email" name="email" required="required"
/><br/><br />
<input type="submit" value=" Submit " name="submit"/><br
/>
</form>
</div>
</div>
<?php
//Attempt server connection with default settings
if(isset($_POST["submit"]))
{
$hostname='localhost';
$username='Sama1991';
$password='xxxxxx';
$name = $_POST ['name'];
$email = $_POST ['email'];
try {
//conects to the database
$dbh = new
PDO("mysql:host=$hostname;dbname=116",$username,$password);
$dbh->setAttribute(PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION);
// adds info to the database
$sql = "INSERT INTO ContactInfo (name, email)
VALUES ('$name', '$email')";
if ($dbh->query($sql)) {
echo "<script type= 'text/javascript'>alert('New Record has
been Inserted Successfully');</script>";
}
else{
echo "<script type= 'text/javascript'>alert('Data not
Inserted.');</script>";
}
$dbh = null;
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Duplicate Word Remover</title>
<link rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
crossorigin="anonymous">
</head>
<body>
<form action="" method="post">
<label>Name :</label>
<input type="text" name="name" required="required"
placeholder="Please Enter Name"/><br /><br />
<label>Email :</label>
<input type="email" name="email" required="required"
/><br/><br />
<input type="submit" value=" Submit " name="submit"/><br
/>
</form>
</div>
</div>
<?php
//Attempt server connection with default settings
if(isset($_POST["submit"]))
{
$hostname='localhost';
$username='Sama1991';
$password='xxxxxx';
$name = $_POST ['name'];
$email = $_POST ['email'];
try {
//conects to the database
$dbh = new
PDO("mysql:host=$hostname;dbname=116",$username,$password);
$dbh->setAttribute(PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION);
// adds info to the database
$sql = "INSERT INTO ContactInfo (name, email)
VALUES ('$name', '$email')";
if ($dbh->query($sql)) {
echo "<script type= 'text/javascript'>alert('New Record has
been Inserted Successfully');</script>";
}
else{
echo "<script type= 'text/javascript'>alert('Data not
Inserted.');</script>";
}
$dbh = null;
// Create connection
$conn = new mysqli("localhost", $username, $password, "116");
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT name, email FROM ContactInfo";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "Name: " . $row["name"]. " <br>Email: " .
$row["email"]."<br><br>";
}
} else {
echo "0 results";
}
$conn->close();
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
?>
</body>
</html>
How can I print the Database table in PHP please ? here I have form for name and email, also I have php code that allow...
For this code below, I need to add the form information to mysql when I click on submit, at the same time when I click on submit I need to move to another page like Welcome.php WITH NOTE THAT THE ENTERED INFORMATION NOW ALREADY IN DATABASE how can I male that with my code below? THANKS ................................................................................................................................................ <form method="POST"> <div class="container"> <label for="fname"><b>First Name</b></label> <input type="text" placeholder="Enter First Name" name="fname" required> <label for="lname"><b>Last Name</b></label> <input type="text" placeholder="Enter Last Name"...
LANGUAGE JAVASCRIPT, PHP
Need help with PHP and ajax code. The user needs to login but, I
keep getting an error that I coded "Wrong username and password!"
***PLEASE DONT GIVE ME A NEW CODE THAT IS NOWHERE NEAR
THE CODE I SUBMITTED***** PLEASE LOOK AT THE CODE AND SEE ANY
ISSUES
login.html
<!DOCTYPE html>
<html>
<head>
<title>login popup</title>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<style type="text/css">
body {
background-color: white;
}
</style>
</head>
<body>
<center>
<h1 style="text-align: center;"> Login </h1>
<form>
Login
ID:...
PHP code that is given :
<?php
// Here is where your preprocessing code goes
// An example is already given to you for the First Name
$fname = $_GET['fname'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Exercise 2 - GET Echo</title>
<style>
body {
margin:0;
padding:0;
font-family: Arial;
}
form {
margin:20px;
}
input[type="text"], input[type="password"] {
width:150px;
padding:3px;
font-size:1em;
}
input[type="submit"] {
padding:3px;
font-size:1em;
}
label {
display:inline-block;
width:150px;
}
.input-container {
padding:5px;
}
</style>
</head>
<body>
<form...
Hey Guys I am doing a project and need some help with code in HTML and PHP. I need a form made in HTML that can be sent to a specific email through PHP. For some reason the info is not getting sent to my email, even though it says that it was sent. I have some source code here: <?php if(isset($_POST['submit'])) { $name = $_POST['name']; $email = $_POST['email']; $subject = $_POST['subject']; $message = $_POST['message']; $email = mail('MY_EMAIL', $subject, $message,...
I need help showing the first column of the table to show up exactly with the mysql table into the php page. Is there a way to fix it ? So I created a php form where the user enters the information. sand.truman.edu/~jyl6557/assignment5/hw5-dataentry.php . it asks for name, hometown, gender(only male and female) and status (freshman, sophmore, junior, senior). once it checks and passes through those tests, it would say added successfully and then show the links to add another...
PHP
Can't get my code to work, what am I doing wrong?
<!DOCTYPE html>
<html>
<head>
<script>
</script>
</head>
<body>
<h2>Temperature Conversion Table</h2>
<h4>Enter a starting value in degrees Fahrenheit and an
increment value.</h4>
<form name="myTemp"
onsubmit="convertCelcius()" method="post">
<input type="text" name="temperature"> Enter an value in
degrees Fahrenheit<br><br>
<input type="radio" name="degIncrement" id="degIncrement5">
Convert in increment in 5 degrees<br>
<input type="radio" name="degIncrement" id="degIncrement10">
Convert in increment in 10 degrees
<br/><br/><input type="submit"
value="Submit">
</form>
<?php
if( $_POST["temperature"] || $_POST["degincrement"] ) {
//get he...
PHP - Use of classes This is a further development of the previous task, the participant registration. You must use the following Participant class. <?php class Deltaker { private $etterNavn; private $forNavn; private $fAar; function __construct(string $fornavn, string $etternavn, string $aar) { $this->forNavn = $fornavn; $this->etterNavn = $etternavn; $this->fAar = $aar; } function hentEtterNavn() : string { return $this->etterNavn; } function hentForNavn() : string { return $this->forNavn; } function hentFAar() : string{ return $this->fAar; } //Setters function settForNavn(string $fornavn) {...
NEED HELP with HTML with Javascript embedding
for form validation project below. I have my code
below but I'm stuck with validation. If anyone can fix it, I'd
really appreciate.
******************************************************************************
CODE:
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project
Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<title>Nice</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<script>
var textFromTextArea;
function getWords(){
var text =...
PHP : I need to make a table in database that holds three fields. A unique key, a name, and an email. then I have to make two PHP files. One of those files has a form with two fields that allow the user to enter their name and email. This file then enters that data into the database table and acknowledges the entry. The second PHP file does a query on that database and prints out a table with ...
Modify the following file, so that: If the user input for the age input box is empty, please send the user a warning message: “Age field cannot be empty” and return to the form web page to allow the user to re-input the age; If the user input for the age input box is incorrect (e. g. less than 1), please also send the user a warning message: “Your age input is not correct!” and return to the form web...