Look up MX server and display - php

I'm trying to make a script that receives "email" in GET and then displays MX server and i tired this code it did not work!
<?php
$email = $_GET['email'];
list($username,$domain) = split("#",$email);
echo getmxrr($domain)
?>

Found the answer
<?php
//$email = $_GET['email'];
//list($username,$domain) = split("#",$email);
//echo getmxrr($domain)
$email = $_GET['email'];
list($username,$domain) = split("#",$email);
$mxlist = array();
echo getmxrr($domain,$mxlist);
foreach($mxlist as $value){
echo $value . "<br>";
}
?>

Related

Correct syntax in Controller.php

In View.php file <?php echo $ticket->player_id ?> is working. But in controller.php it is not working. What is the correct syntax for Controller.php?
I am trying to use it here
'include_player_ids' => array('<?php echo $ticket->player_id ?>'),
The following is the sample code from controller file which are working properly
// Send Email
$email_template = $this->home_model->get_email_template_hook("ticket_reply", $lang);
if($email_template->num_rows() == 0) {
$this->template->error(lang("error_48"));
}
$email_template = $email_template->row();
if(isset($ticket->client_username)) {
$username = $ticket->client_username;
$email = $ticket->client_email;
$first_name = $ticket->first_name;
$last_name = $ticket->last_name;
} else {
$username = $ticket->guest_email;
$email = $ticket->guest_email;
$first_name = $ticket->guest_email;
$last_name = "";
}
In controller.php ,
$data['ticket'] = 'your data will be here';
In view.php,
'include_player_ids' => array($ticket->player_id),
Hope you understand.
Its already in php tags so you do not need to place <?php ?> again just assign variable directly
'include_player_ids' => array($ticket->player_id),
It should be
'include_player_ids' => array($ticket->player_id),
Please post the output of $ticket

alert shows entry updated succesfully but entry does'nt update in database

I am creating a updating form page. it shows no error but there is no updation in my database.
I already check whole the database row names but that doesnt help.
that code is a little bit long but please help.
<?php
if (isset($_POST['update'])) {
$update_id = $_GET['edit_form'];
$bill = $_POST['b_no'];
$naam = $_POST['name'];
$mobile_no = $_POST['mobile'];
$addres = $_POST['add'];
$detail = $_POST['p_detail'];
$p_img_name = $_FILES['p_img']['name'];
$p_img_type = $_FILES['p_img']['type'];
$p_img_size = $_FILES['p_img']['size'];
$p_img_tmp = $_FILES['p_img']['tmp_name'];
$prc = $_POST['price'];
$deposite = $_POST['d_amt'];
$remaning = $_POST['r_amt'];
$b_img_name = $_FILES['b_img']['name'];
$b_img_type = $_FILES['b_img']['type'];
$b_img_size = $_FILES['b_img']['size'];
$b_img_tmp = $_FILES['b_img']['tmp_name'];
$p_date = date('y-m-d');
move_uploaded_file($p_img_tmp, "images/Product/$p_img_name");
move_uploaded_file($b_img_tmp, "images/Bill/$b_img_name");
$update_query = "UPDATE new_entry SET bill_no='$bill', name='$naam',
mobile_no='$mobile_no', address='$addres', product_detail='detail',
product_image='$p_img_name', price='$prc', deposite_amt='deposite',
remaining='$remaning', bill_image='$b_img_name',Product_date='$p_date'
WHERE s_no='$update_id' ";
if(mysqli_query($conn, $update_query)) {
echo "<script> alert('Entry Updated Successfully') </script>";
echo "<script> window.open('view_entry.php','_self') </script>";
} else {
echo "cant Update Entry.." .mysqli_error($conn);
}
}
?>

pdo query successfully run on localhost but not run on hosting

My code is below it is running on the localhost successfully but not running on hosting server. i tried many time to resolve but i am not able to solve it
<?php
include ('dbconfig.php');
$page = isset($_GET['p'])?$_GET['p']:'';
if($page =='add'){
$email_id = $_POST['email_id'];
$customer_name = $_POST['customer_name'];
$mobile_no = $_POST['mobile_no'];
$address = $_POST['adress'];
$city = $_POST['city'];
$state = $_POST['state'];
$country = $_POST['country'];
$no_of_jurney_person = $_POST['no_of_jurney_person'];
$j_from = $_POST['j_from'];
$j_to = $_POST['j_to'];
$date_of_jurney = $_POST['date_of_jurney'];
$return_date = $_POST['return_date'];
$stmt=$DBcon->prepare("insert into anil values('',?,?,?,?,?,?,?,?,?,?,?,?)");
$stmt->bindParam(1,$email_id);
$stmt->bindParam(2,$customer_name);
$stmt->bindParam(3,$mobile_no);
$stmt->bindParam(4,$address);
$stmt->bindParam(5,$city);
$stmt->bindParam(6,$state);
$stmt->bindParam(7,$country);
$stmt->bindParam(8,$no_of_jurney_person);
$stmt->bindParam(9,$j_from);
$stmt->bindParam(10,$j_to);
$stmt->bindParam(11,$date_of_jurney);
$stmt->bindParam(12,$return_date);
if($stmt->execute()){
echo "Mr. Or Mrs ".$customer_name;
echo "Thanks for inquiry. Our representative will call you soon";
}
else{
echo "Something went wrong. Please try again later";
}

PHP Login using a txt file

hello I am working on a project where i have to create a php login using a text file. I have the basic code laid out but when I put a username and password on file and try signing in, it does not work. I could really use some advise. thank you. The code below is my login php file.
<?php
session_start();
$User = $_GET["user"];
$Pass = $_GET["password"];
if (!strpos($User,"#")) {
$User = $User . "#etown.edu";
}
$Validuser = false;
$_SESSION["user"] = $User;
$_SESSION["pass"] = $Pass;
$_SESSION["login"]= $Validuser;
?>
<!DOCTYPE html>
<html>
<body>
<?php
print "<h2>Welcome $User</h2>";
$infile = fopen("account.txt","r");
$entry = fgets($infile);
while (!feof($infile)) {
$array = explode(" ",$entry);
if ($array[0] == $User){
$name = $array[0];
$code = $array[1];
$code = substr($code,0,strlen($code)-1);
}
$entry = fgets($infile);
}
print "Name: $name <br/>";
print "pass on file: $code <br />";
fclose($infile);
if ($name==$User && $code==$Pass)
$Validuser = true;
$_SESSION["login"] = $Validuser;
print "That's All!<br/>";
if ($Validuser) {
print "Welcome valid user<br/>";
}
else {
print "You are not a valid user. Go become one first!";
print '<script type="text/javascript">';
print ' //document.location = "register.html";';
print '</script>';
}
?>
</body>
</html>
try adding this
$User = isset($_GET["user"]) ? $_GET["user"] : '';
$Pass = isset($_GET["user"]) ? $_GET["password"] : '';
$name ='';
$code='';
i'm assuming your txt file is like this
ja#etown.edu 12345
ja2#etown.edu 12345
ja3#etown.edu 12345

Checkbox value not displaying

The form inputs aren't displaying on the form.php page and negates my form validation. The error says undefined variable for all my variables on form.php. Please tell me what I have to edit in my code to make it display the form inputs on form.php. It works when I use it on the same page but I would rather it display on another page.
EDIT
Thanks so far but I can't get the value of the checkbox, the recipient(Administrator or Content Editor), to display it displays "Array" or "A".
contact.php
<?php
$errnam = "";
$errmail = "";
$errsub = "";
$errrec = "";
$hasErrors = false;
if(isset ($_POST['submitted'])){
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$recipient = $_POST['recipient'];
$message = $_POST['message'];
if(preg_match("/^[\w\-'\s]/", $_POST['name'])){
$name = $_POST['name'];
}
else{
$errnam ='<strong>Please enter a name.</strong>';
$hasErrors = true;
}
if (preg_match("/^[\w.-_]+#[\w.-]+[A-Za-z]{2,6}$/i", $email)){
$email = $_POST['email'];
}
else{
$errmail = '<strong>Please enter a valid email.</strong>';
$hasErrors = true;
}
if(preg_match("/^[\w\-'\s]/", $_POST['subject'])){
$subject = $_POST['subject'];
}
else{
$errsub = "<strong>Please enter a subject.</strong>";
$hasErrors = true;
}
if (!empty($_POST['recipient'])) {
for ($i=0; $i < count($_POST['recipient']);$i++) {
$recipient = $_POST['recipient'];
}
}else{
$errrec = "<strong>Please select a recipient</strong>";
$hasErrors = true;
}
$message = $_POST['message'];
}
if ($hasErrors){
echo "<strong>Error! Please fix the errors as stated.</strong>";
}else{
header("Location: form.php?name=".$name."&email=".$email."&subject=".$subject. "&recipient=".$recipient. "&message=".$message);
exit();
}
?>
form.php
<?php
$name = $_GET['name'];
$email = $_GET['email'];
$subject = $_GET['subject'];
$recipient = $_GET['recipient'];
$message = $_GET['message'];
echo "<h2>Thank You</h2>";
echo "<p>Thank you for your submission. Here is a copy of the details that you have sent.</p>";
echo "<strong>Your Name:</strong> ".$name. "<br />";
echo "<strong>Your Email:</strong> ".$email. "<br />";
echo "<strong>Subject:</strong> ".$subject. "<br />";
echo "<strong>Recipient:</strong>" .$recipient. "<br />";
echo "<strong>Message:</strong> <br /> " .$message;
?>
If you would like to transfer the data from contact.php to form.php you should use something like this:
contact.php
$data = urlencode(
serialize(
array(
"name" => $name,
"email" => $email,
"subject" => $subject,
"message" => $message)
));
header('Location: form.php?data=' . $data);
form.php
$data = unserialize(urldecode($_GET['data']));
$name = $data["name"];
$email = $data["email"];
$subject = $data["subject"];
$message = $data["message"];
This serializes the array of data from contact.php then URL encodes it and sends it as a GET variable to form.php. After, form.php URL decodes and unserializes the data for use.
The problem is when you header("Location:") to form.php, all the POST values are lost. You have to either resend them with the header, or modify them into GET and retrieve them again. It should be more efficient to have them both (contact.php AND form.php) in one page. That way, the form data only has to be sent once.
You could probably just send the POST values as GET over to form.php like this.
contact.php:
header("Location: form.php?name=".$name."&email=".$email."&subject=".$subject."&message=".$message);
form.php (to retrieve the values):
$name = $_GET['name'];
$email = $_GET['email'];
$message = $_GET['message'];
$subject = $_GET['subject'];
If you want to display form elements then you have to use this approach.
<form method="POST" action="contact.php">
Email<input type="text" name="email">
.......
.......
.......
// All elements
</form>
This may help you.
Give action in your form in contact.php
<form action="form.php">

Categories