Hello,
Below is the script there are no errors but php is not storing inputted data to mysql.
[php]
Step 1
Please enter the specified information
Number of Items :Name of Raffle :
Slots :
Credit :
SteamID of user :
SteamID of Admin:
<? if($_POST) { $no = $_POST['no']; setcookie("no", $no, time()+120); $nameofraffle = $_POST['nameofraffle']; $slots = $_POST['slots']; $credits = $_POST['credits']; $usteamid =$_POST['usteamid']; $asteamid =$_POST['asteamid']; $otherinfo =$_POST['otherinfo'];
$host = ‘localhost’;
$pass = ‘’;
$user = ‘root’;
$db = ‘test’;
$con=mysqli_connect($host,$user,$pass,$db);
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
mysqli_query($con,“INSERT INTO tstraffle VALUES (’$nameofraffle’,’$slots’,’$otherinfo’,’$credits’,’$usteamid’,’$asteamid’”);
$RID =mysqli_query($con,"SELECT * FROM tstraffle ORDER BY RID DESC LIMIT 1");
setcookie("rid", $RID, time()+120);
if(mysqli_affected_rows($con) >=1)
{
$host = $_SERVER[‘HTTP_HOST’];
$uri = rtrim(dirname($_SERVER[‘PHP_SELF’]), ‘/\’);
$extra = ‘step1.php’;
header(“Location: http://$host$uri/$extra”);
exit;
}
else{
echo ‘did you miss something??? cause its not done…’;
}
mysqli_close($con);
}
?>
[/php]
And this
[php]<?php
/**
-
Created by PhpStorm.
-
User: karan
-
Date: 13/03/14
-
Time: 10:06 AM
*/
$rid = $_COOKIE[‘rid’];
$no = $_COOKIE[‘no’];
if ($_POST)
{
$db = new PDO(“mysql:host=localhost;dbname=test”, “root”, “”);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$insertStmt = $db->prepare(“INSERT INTO items (raffle_id,item,item_info) VALUES (’.$rid.’,?,?)”);for ($i = 0; $i < count($_POST[‘field1’]); $i++)
{
$insertStmt->execute(array(
$_POST[‘item’][$i],
$_POST[‘q’][$i]
));
}
if(mysqli_affected_rows($con) >=1)
{
echo ‘Done,Please check the raffle page.’;
}
else{
echo ‘did you miss something??? cause its not done…
or CONTACT FROST ALMIGHTY’;
}
}
?>
<? for ($x = 0; $x <= $no; $x++) { echo "Item $x:\n"; echo "Quality$x :
\n"; }
?>[/php]
Thanks