-
Notifications
You must be signed in to change notification settings - Fork 0
/
page-updateUser.php
65 lines (48 loc) · 1.7 KB
/
page-updateUser.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/*
Template Name: Update Users
*/
?>
<?php get_header(); ?>
<?php
session_start();
if (isset($_POST["contactName"]) && !empty($_POST["contactName"])) {
$table = $_SESSION['name'];
$servername = "127.0.0.1";
$username = "root";
$password = "root";
$dbname = "demo_wordpress";
$name = $_POST['contactName'];
$email = $_POST['email'];
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname , 8889);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "UPDATE $table SET email = '$email' WHERE name = '$name';";
if ($conn->query($sql) === TRUE) {
echo "Updated successfully";
header("Location: http://localhost:8888/home-page/");
}
}
?>
<form id="contactForm" method="post">
<ol class="forms">
<li><label for="contactName">Name</label>
<input type="text" name="contactName" id="contactName" value="" required />
<?php if($nameError != '') { ?>
<span class="error"><?=$nameError;?></span>
<?php } ?>
</li>
<li><label for="email">Email</label>
<input type="text" name="email" id="email" value="<?php if(isset($_POST['email'])) echo $_POST['email'];?>" required />
<?php if($emailError != '') { ?>
<span class="error"><?=$emailError;?></span>
<?php } ?>
</li>
<li class="buttons"><input type="hidden" name="submit" id="submitted" value="true" /><button type="submit">Update Email »</button></li>
<!--<li class="buttons"><input type="button" name="submitted" id="submitted" value="Check list of users" onClick=" location='http://localhost:8888/82-2/ '" /></li> -->
</ol>`
</form>
<?php get_footer(); ?>