Click here to Skip to main content
15,030,320 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
PHP
  1  <?php  
  2  
  3  
  4  include 'connect.php'; 
  5  
  6  $nama=$_GET['updatenama'];
  7  
  8  if(isset($_POST['submit'])){ 
  9  	$nama=$_POST['nama']; 
 10  	$jawatan=$_POST['jawatan']; 
 11  	$telefon=$_POST['telefon']; 
 12  	$sem=$_POST['sem']; 
 13  	$cgpa=$_POST['cgpa']; 
 14  	$matrik=$_POST['matrik']; 
 15  	$penasihat=$_POST['penasihat']; 
 16  	$email=$_POST['email']; 
 17  	$telefonpenasihat=$_POST['telefonpenasihat']; 
 18  	$pengiring1=$_POST['pengiring1']; 
 19  	$telefonpengiring1=$_POST['telefonpengiring1']; 
 20  	$pengiring2=$_POST['pengiring2']; 
 21  	$telefonpengiring2=$_POST['telefonpengiring2']; 
 22  
 23  	$sql="update `butir` set nama='$nama', jawatan='$jawatan', telefon='$telefon', sem=$sem, cgpa=$cgpa, matrik=$matrik, penasihat='$penasihat', email='$email', telefonpenasihat='$telefonpenasihat', pengiring1='$pengiring1', telefonpengiring1='$telefonpengiring1', pengiring2='$pengiring2', telefonpengiring2='$telefonpengiring2'"; 
 24  
 25  	$result=mysqli_query($con,$sql); 
 26  
 27  	if($result){ 
 28  	 	echo "Updated successfully"; }
 29  	 	//header('location:display.php');
 30  	 //}
 31  	 else{ 
 32  	 	die(mysqli_error($con)); 
 33  	 } 
 34  //}
 35  
 36  
 37  ?>
 38  
 39  <!doctype html>
 40  <html lang="en">
 41    <head>
 42      <!-- Required meta tags -->
 43      <meta charset="utf-8">
 44      <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
 45      <!-- Bootstrap CSS -->
 46      <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" >
 47      <title>C</title>
 48      <style>
 49  	    	/* style for table  */
 50  	table, th, td {
 51  	  border: 2px solid black;
 52  	  border-collapse: collapse;
 53  	}
 54  	th, td {
 55  	  padding: 5px;
 56  	  text-align: left;  
 57  	  }
 58  	  .main {   
 59    flex: 70%;
 60    background-color: #FEEB75;
 61    padding: 20px;
 62  }
 63  	  .header {
 64  		  background-color: #8D4585;
 65  		  padding: 100px;
 66  		  text-align: center; 
 67  	}
 68  	  .topnav {
 69  	  overflow: hidden;
 70  	  background-color: #FCF3CF ;
 71  	  text-align: center;
 72  	  font-family: "Lucida Console", "Courier New", monospace;
 73  	}
 74  	.topnav a {
 75  	  float: left;
 76  	  display: block;
 77  	  color: black;
 78  	  text-align: center;
 79  	  padding: 14px 16px;
 80  	  text-decoration: none;
 81  	}
 82  	.topnav a:hover {
 83  	  background-color: #E8DAEF;
 84  	  color: black;
 85  	  }
 86      </style>
 87    </head>
 88  
 89    <body>
 90  
 91    	<div class="header">
 92  		 <font face = "Verdana" size ="6">    BORANG PERMOHONAN AKTIVITI PELAJAR <br>
 93      BAHAGIAN HAL EHWAL PELAJAR <br>
 94      UNIVERSITI TEKNOLOGI MARA  </font><br />
 95  	</div>
 96  	<div class="topnav">
 97    <a href="user2.php">A: RINGKASAN PERMOHONAN AKTIVITI PELAJAR B: IMPAK AKTIVITI</a> 
 98    <a href="user.php">C: BUTIR PEMOHON</a> 
 99    <a href="user3.php">E: MAKLUMAT PERBELANJAAN</a>
100  	</div>
101  	<div class="main">
102    	<div class="container my-5">
103  	<form method="post"> 
104  
105  <!-- BAHAGIAN C -->
106    		<table style="width: 80%">
107  	  	<tr>
108  	    <th style="color:white; background-color:black;" colspan="4"  id="partC">C: BUTIR PEMOHON</th>
109  	  </tr>
110  	  <tr>
111  	    <th colspan="2">NAMA PENGARAH PROGRAM:
112  	  <input type="text" class="form-control" name="nama" autocomplete="off"></th>
113  	  </tr>
114  	  <tr>
115  	  <th>Jawatan Dalam Persatuan :
116  	  <input type="text" class="form-control" name="jawatan" autocomplete="off"></th>
117  	  <th>No. Telefon Bimbit :
118  	  <input type="tel" class="form-control" name="telefon" autocomplete="off"></th>
119  	  </tr>
120  	  <tr>
121  	  <th>Semester :
122  	  <input type="text" class="form-control" name="sem" autocomplete="off"></th>
123  	  <th>CGPA Semasa
124  	    (Dicadangkan 3.00 ke atas):</td>
125  	  <input maxlength="4" size="4" class="form-control" name="cgpa" autocomplete="off"></th>
126  	  </tr>
127  	  <tr>
128  	  <th colspan="2">No. Kad Pelajar :
129  	  <input type="text" class="form-control" name="matrik" autocomplete="off"></th>
130  	  </tr>
131  	  <tr>
132  	  <th colspan="2">NAMA PENASIHAT PERSATUAN :
133  	  <input type="text" class="form-control" name="penasihat" autocomplete="off"></th>
134  	  </tr>
135  	  <tr>
136  	  <th>Email :
137  	  <input type="text" class="form-control" name="email" autocomplete="off"></th>
138  	  <th>No. Telefon Bimbit :
139  	  <input type="text" class="form-control" name="telefonpenasihat" autocomplete="off"></th>
140  	  </tr>
141  	  <tr>
142  	  <th colspan="2">PEGAWAI PENGIRING (Sekiranya Ruangan Tidak Mencukupi Sila Buat Lampiran)</th>
143  	  </tr>
144  	  <tr>
145  	  <th>i) Nama :
146  	  <input type="text" class="form-control" name="pengiring1" autocomplete="off"></th>
147  	  <th>No. Telefon Bimbit :
148  	  <input type="text" class="form-control" name="telefonpengiring1" autocomplete="off"></th>
149  	  </tr>
150  	  <tr>
151  	  <th>ii) Nama :
152  	  <input type="text"  name="pengiring2" class="form-control" autocomplete="off"></th>
153  	  <th>No. Telefon Bimbit :
154  	  <input type="number" class="form-control" name="telefonpengiring2" autocomplete="off"></th>
155  	  </tr>
156  	</table> 
157  	<br>
158  	<center>
159  	<button type="submit" class="btn btn-primary" name="submit">Update</button>
160  	</center>
161  </form>
162  
163  	</div>
164  
165  </div>
166  
167    </body>
168  
169  </html>


What I have tried:

I've tried everything but seems not working.

the error is :
Parse error: syntax error, unexpected end of file in C:\wamp64\www\trycrud\update.php on line 158
Posted
Updated 19-Jul-21 0:28am
v2
Comments

Chris C is correct, but not at that point:
PHP
if(isset($_POST['submit'])){  <-- this open brace is not being closed
	$nama=$_POST['nama']; 
	$jawatan=$_POST['jawatan']; 
	$telefon=$_POST['telefon']; 
	$sem=$_POST['sem']; 
	$cgpa=$_POST['cgpa']; 
	$matrik=$_POST['matrik']; 
	$penasihat=$_POST['penasihat']; 
	$email=$_POST['email']; 
	$telefonpenasihat=$_POST['telefonpenasihat']; 
	$pengiring1=$_POST['pengiring1']; 
	$telefonpengiring1=$_POST['telefonpengiring1']; 
	$pengiring2=$_POST['pengiring2']; 
	$telefonpengiring2=$_POST['telefonpengiring2']; 

	$sql="update `butir` set nama='$nama', jawatan='$jawatan', telefon='$telefon', sem=$sem, cgpa=$cgpa, matrik=$matrik, penasihat='$penasihat', email='$email', telefonpenasihat='$telefonpenasihat', pengiring1='$pengiring1', telefonpengiring1='$telefonpengiring1', pengiring2='$pengiring2', telefonpengiring2='$telefonpengiring2'"; 

	$result=mysqli_query($con,$sql); 

	if($result){ <-----------------------------these two
	 	echo "Updated successfully"; } <-------match
	 	//header('location:display.php');
	 //}
	 else{ <------------------------and these two
	 	die(mysqli_error($con)); 
	 } <----------------------------also match
//} <----but this one is commented out so the first if clause is not terminated.
   
Comments
Iman 2021 20-Jul-21 10:49am
   
thank you! i didn't notice that
Richard MacCutchan 20-Jul-21 11:09am
   
You're welcome. Always a challenge to spot these ones.
Disregard this answer, Richard has posted the correct one above!
   
v3
Comments
OriginalGriff 19-Jul-21 6:14am
   
Um ... are you sure:
if($result){ 
 	echo "Updated successfully"; }
                                 ^
                                 |
 	//header('location:display.php');
} // <-- this is needed to close the { from above
Chris Copeland 19-Jul-21 7:01am
   
D'oh, my bad. That's what I get for posting while in a call!
Richard MacCutchan 19-Jul-21 9:12am
   
We've all done it (me more than most). :(
Iman 2021 20-Jul-21 10:49am
   
thank you!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900