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";
}
Related
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>";
}
?>
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);
}
}
?>
I have a query to insert but idk how to insert function and session into my database.
Thanks for helping!!
<?php
if (isset($_POST['submit'])){
$address = $_POST['address'];
$poscode = $_POST['poscode'];
$city = $_POST['city'];
$state = $_POST['state'];
$tel_no = $_POST['tel_no'];
$recipient = $_POST['recipient'];
$date = $_POST['date'];
$image = $_FILES['image']['name'];
$image_tmp = $_FILES['image']['tmp_name'];
move_uploaded_file($image_tmp,"receipt/$image");
$insert_order = "insert into user_order(user_email,total_payment,address,poscode,city,state,tel_no,recipient,payment_status,image,date) values ('{$_SESSION['user_email']}','".total_price()."','$address','$poscode','$city','$state','$tel_no','$recipient','pending','$image','$date')";
$insert_order = mysqli_query($con, $insert_order);
if($insert_order){
echo "<script>alert('Order has been placed!')</script>";
echo "<script>window.open('user/my_account.php','_self')</script>";
}}
?>
Please add the this line after the php tag opening.
session_start();
Without starting the session you cant use the session variables in php.
This is works in my case. Please have a try.
I'm working on a classifieds I'm setting up for my site and I've found myself "Stuck" again.
I'm new to PHP but I'm working on developing a better mouse trap for the classifieds and the script I will provide below I have written entirely from scratch and it works. (uploads data to the DB) but when I add the if block starting with: if($_POST['Image 1'] != "") { the whole thing crashes. (I get a white screen with no error messages or anything).
Here's the full code for this page;
<?php
ob_start();
session_start();
require_once('z-mysql_ini.php');
require ('z-connect.php');
$mysql = new mysql();
if($_POST['Description'] != "") {
$TypeID = $_POST['TypeID'];
$FatherID = $_POST['fatherID'];
$Model = $_POST['Model'];
$Price = $_POST['Price'];
$Description = $_POST['Description'];
$Year = $_POST['Year'];
$VIN = $_POST['VIN'];
$Address = $_POST['Address'];
$City = $_POST['City'];
$State = $_POST['State'];
$ZIP = $_POST['ZIP'];
$Country = $_POST['Country'];
$Email = $_POST['Email'];
$Phone = $_POST['Phone'];
$InformOfUpdates = $_POST['Inform'];
}
$node = new sqlNode();
$node->table = sprintf("`tt_%s`", abs(intval($_POST['TypeID'])));
$node->push("int", "CategoryID", $FatherID);
$node->push("int", "MemberID", $_SESSION['memberID']);
$node->push("text", "Model", strtoupper($Model));
$node->push("int", "Price ($)", $Price);
$node->push("text", "Description", $Description);
$node->push("int", "Year", $Year);
$node->push("text", "VIN", $VIN);
$node->push("defined","PostDate","NOW()");
$node->push("text","Featured","yes");
$node->push("defined","ExpireDate","DATE_ADD(NOW(),INTERVAL 30 DAY)");
$node->push("text", "Address", $Address);
$node->push("text", "City", $City);
$node->push("text", "State/Province", $State);
$node->push("text", "ZIP/Postal", $ZIP);
$node->push("text", "Country", $Country);
//$node->push("text", "Email", $Email);
//$node->push("text", "Phone", $Phone);
$node->push("int", "Inform", $InformOfUpdates);
if(($result = $mysql->insert($node)) === false) {
echo mysql_error();
echo 'Unable to Insert Data';
} else {
$ListingID = mysql_insert_id();
}
if($_POST['Image 1'] != "") {
echo 'File Selected and Data set in DB';
} else{
echo 'No File Selcted but Data Inserted';
//header("Location:memberindex.php");
}
}
?>
If anyone could kindly show me what I'm doing wrong that's making the page crash, I'd be most appreciative as then I can move forward with re-implementing the image upload code that came with the classifieds, but I can't even get past this initial block of test code without the page dying (and not uploading to the DB.
Bottom line is if I take the following code off of the page entirely, the script will upload all of the variable data above into the DB but if I add this block of code the whole thing crashes.
if($_POST['Image 1'] != "") {
echo 'File Selected and Data set in DB';
} else{
echo 'No File Selcted but Data Inserted';
//header("Location:memberindex.php");
}
Ok So i have an PHP page and i have a database.
In my database i have a table with a Field one of the fields is called accounttype it is enum('n', 'm', 's')
I am trying to display on my PHP page if the user is N it should say Normal User if the user is E Expert user or S Super user...
How do i go about doing this?
Top of PHP Page
<?php
// Query member data from the database and ready it for display
$sql = mysql_query("SELECT * FROM members WHERE id='$id' LIMIT 1");
while($row = mysql_fetch_array($sql)){
$phone = $row["phone"];
$country = $row["country"];
$state = $row["state"];
$city = $row["city"];
$accounttype = $row["accounttype"];
$bio = $row["bio"];
}
?>
Where i am trying to display on the page This is the code. Right now it just puts a blank space.
<span class="admin">Edward</span>
<span class="date">March 19, 2048</span>
<span class="tag"><?php echo "$accounttype"; ?></span>
<span class="comment">166 comments</span>
picture
http://i.stack.imgur.com/KXu9A.png
first make a connection, than dont make a while, make a if like this
if($row = mysql_fetch_array($sql)){
$phone = $row["phone"];
$country = $row["country"];
$state = $row["state"];
$city = $row["city"];
$accounttype = $row["accounttype"];
$bio = $row["bio"];
}
and than
$speaking_type = null;
switch($accounttype) {
case 'n':
$speaking_type = 'Normal User';
break;
case 'm':
$speaking_type = 'Expert User';
break;
case 's':
$speaking_type = 'Super User';
break;
default:
$speagink_type = 'none';
//throw new Exception('unsupported account type '.$accounttype);
}
echo $speaking_type;
I think the problem is your scope. Your variables are defined within the while-loop, and so they are unknown further in the document. Try instantiating them on top (before the while-loop) like this:
$phone = null;
$country = null;
$state = null;
$city = null;
$accounttype = null;
$bio = null;
Than the variables will be known outside the while and the values will be remembered when you print them.
I thought u didn't connect to the database first .use following code to the connect with your credentials.That's why you are seeing a blank space
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
// some code
mysql_close($con);