Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

Help Web developers Php mysqli

shestheman

Proficient
Advanced Member
Messages
250
Reaction score
1
Points
28
Pa help naman po kung tama ginawa ko gusto ko kasi mangyari bago ako maka pag Insert sa table na Student_enrolled ay mag match yung email nya dun sa account nya sa table ng Useraccount,, bali di sya makakapag insert pag di nag match yung account email nya sa Useraccount

<?php

if(isset($_POST['enrollstudent'])) {
$studentid = $_POST['studentid'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$myemail = $_POST['email'];

}else{
header("location:./");
}
include '../db_config/connection.php';

$sql = "SELECT * FROM admin_info where email LIKE '$myemail'";
$result = $conn->query($sql);

if ($result->num_rows > 0) {

while($row = $result->fetch_assoc()) {
$student = $row['first_name'];
header("location:my_class.php?msg=Email $myemail does not match any account in database");
}

}
else {
include '../db_config/connection.php';
$class_id = $_GET['ref'];
$sql = "INSERT INTO student_enrolled (userid, student_id, firstname, lastname, email, class_id)
VALUES ('$userid', '$studentid', '$firstname', '$lastname', '$myemail', '$class_id')";

if ($conn->query($sql) === TRUE) {
header("location:my_class.php?ref=$class_id&?message= have been successfully registered");
} else {
$error = $conn->error;
header("location:my_class.php?err=$error");
}
$conn->close();
}
$conn->close();
?>
 

Attachments

  • Capture.PNG
    Capture.PNG
    58.2 KB · Views: 9
Pa help naman po kung tama ginawa ko gusto ko kasi mangyari bago ako maka pag Insert sa table na Student_enrolled ay mag match yung email nya dun sa account nya sa table ng Useraccount,, bali di sya makakapag insert pag di nag match yung account email nya sa Useraccount


$sql = "SELECT * FROM admin_info where email LIKE '%".$myemail."%'"

}
else {
include '../db_config/connection.php'; <- hindi mo na kailangan i call pa ito ulit
$class_id = $_GET['ref'];

- - - Updated - - -

<?php
include '../db_config/connection.php';

if(isset($_POST['enrollstudent']))
{
$class_id = $_GET['ref'];
$studentid = $_POST['studentid'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$myemail = $_POST['email'];

$sql = "SELECT * FROM admin_info where email LIKE '%".$myemail."%'";
$result = $conn->query($sql);

if ($result->num_rows > 0)
{
while($row = $result->fetch_assoc())
{
$student = $row['first_name'];
header("location:my_class.php?msg=Email $myemail does not match any account in database");
}
}else {
$insert = "INSERT INTO student_enrolled (userid, student_id, firstname, lastname, email, class_id)
VALUES ('".$userid."', '".$studentid."', '".$firstname."', '".$lastname."', '".$myemail."', '".$class_id."')";
$insertQuery = $conn->query($insert);
if($insertQuery)
{
header("location:my_class.php?ref=$class_id&?messa ge= have been successfully registered");
} else {
$error = $conn->error;
header("location:my_class.php?err=$error");
}
}
}else{
header("location:./");
}

$conn->close();
?>
 
Last edited:
kokontrahin na kita sa gagawin mo ha. Bakit like? at bakit %%? kapag naglagay ako ng letter "a" lang, pasok agad yung entry... GL

email like '%a%'
 
Last edited:
hahaha! yun lang.. di ko alam y like ang natipuhan nya :D

$sql = "SELECT * FROM admin_info where email = '".$myemail."'";
 
pwede naman direct na kaagad yan WHERE `email`='$email'
 
walang basagan ng trip LIKE gusto nya e :lol:
anyway para kay ts yung LIKE is to match each character according sa gusto mo hanapin.
kung gusto mo mag match yung email, select mo with equal operator. Like sir eug said.
 
Back
Top Bottom