This is the code to display the details ( postfunction.ph p) -
<?php
-
-
// Connection data (server_address, database, username, password)
-
$dbhost = 'localhost';
-
$dbname = 'posting';
-
$dbuser = 'root';
-
$dbpass = '';
-
-
// Display message if successfully connect, otherwise retains and outputs the potential error
-
-
try {
-
$conn = new PDO("mysql:host=$dbhost; dbname=$dbname", $dbuser, $dbpass);
-
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
-
}
-
-
catch(PDOException $e)
-
{
-
echo $e->getMessage();
-
}
-
-
try
-
{
-
$query = $conn->prepare("SELECT * FROM review WHERE pid = :pid");
-
$query->execute(array(':pid' => $_GET['pid'],));
-
}
-
-
catch (PDOException $e)
-
{
-
error_log($e->getMessage());
-
die($e->getMessage());
-
}
-
-
-
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
-
//Details..
-
}
-
$conn=null;
-
Theres a form in that page to submit the review .
When i submit the form it displays an error saying :Undefined index: pid in C:\wamp\www\New \signup\postfun c.php on line 25
Heres the form -
<form action="ins.php" method="post">
-
<input type="hidden" name="pid" value="<? . $row['pid'] . ?>" />
-
<input type="hidden" name="id" value="<? . $row['id'] . ?>" />
-
<input type="text" name="review" />
-
<input name="submit" type="submit" value="Submit"/>
-
</form>
-
Line 25 is : $query->execute(array( ':pid' => $_GET['pid'],));
I have used $_GET['pid'] because on my other page there are links . When i click on those , they get displayed in this page ( postfunction.ph p) by getting the pid of those links .
What am i missing ?
2 2523
You are trying to retrieve data from a get request while your form is POST not get.
The code for inserting form data is below : -
<?php
-
-
// Connection data (server_address, database, username, password)
-
$dbhost = 'localhost';
-
$dbname = 'posting';
-
$dbuser = 'root';
-
$dbpass = '';
-
-
// Display message if successfully connect, otherwise retains and outputs the potential error
-
-
try
-
{
-
$conn = new PDO("mysql:host=$dbhost; dbname=$dbname", $dbuser, $dbpass);
-
echo 'Connected to database';
-
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
-
}
-
-
catch(PDOException $e)
-
{
-
echo $e->getMessage();
-
}
-
-
try
-
{
-
$query = $conn->prepare("INSERT INTO `comment` (review,pid,id) VALUES (:review, :pid,:id)");
-
-
$query->execute(
-
array(
-
'review' => $_POST['review'],
-
'pid' => $_POST['pid'],
-
'id' => $_POST['id'],
-
));
-
}
-
-
catch (PDOException $e)
-
{
-
error_log($e->getMessage());
-
die($e->getMessage());
-
}
-
-
$dbh = null;
-
-
header('location: post.php');
-
-
exit();
-
-
?>
-
I want to insert form data into this table - rid - //id of review table
- review - //review text entered by user
- pid - //id from review table
- id - //id from user table
-
So when i submit , it displays that error . postfunction.ph p is only for displaying the details of the review . There is no form for that .
How do i solve this . I am confused in linking these .
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Chris |
last post by:
I have a simple search feature that searches 3 fields in 3 separate tables
in a MySQL db, and I'm getting an 'undefined index' error, but only in the
first section (first table)of the results. The undefined index is tied to
the docs.projID in the "if ($row_search == 1)". This if
statement is there to control to format of the link as pages...
|
by: shalini11 |
last post by:
Hello,
I am using a page that has a dropdown list. when the user selects an item from the list and click on submit button, it opens a new page and displays the selected item.
I've used as method in my form. and request to retrieve the selected value:
<form method="POST" name="frmcriteria" action="test.php" target="_blank" onsubmit="return...
|
by: jsgoodrich |
last post by:
I am looking for some help if anyone can lend a hand.
I have a simple php website that displays a table from my mysql
database.
To prep for my MCSE I moved my home server to Windows 2003 Standard, I
installed mysql and php 5 to run some of my databases and websites.
Under Linux the site worked fine, under windows I keep getting Notice...
|
by: JJM0926 |
last post by:
I've got a contact form with a submit button where users have to enter
their support information. Some fields are required some are not.
When I test out the form if I leave everything blank I get these two
undefined index error :
Notice: Undefined index: CurrentCustomer in E:\WebSites\mysite\www
\contactus.php on line 9
Notice:...
|
by: ridgedale |
last post by:
I wonder if anyone can help resolve an issue I've come across in making a customer's website live when it has tested fine in my own hosting space.
I am getting the following errors: Notice: Undefined index: vartalk
For reference I provide the following links:
My hosting space (where everything appears to be working fine):...
| |
by: Philth |
last post by:
Hey there, it has to be said that I am a complete novice in PHP, I know this is a common error and has probably been covered to some degree already - but my head really does hurt - so I couldn't stand trawling through anymore forums hunting for the right answer. Anyway - here goes.
The page I'm having trouble with is a simple edit row type...
|
by: jason1987 |
last post by:
I keep getting the undefined index error on the bottom two rows of my code simparent and equtype - the other two work fine yet there is no difference in my code. equtypeid is even from the same table as the top two
$equid=$HTTP_POST_VARS;
$fromuserid=$HTTP_POST_VARS;
$simparent=$HTTP_POST_VARS;
$equtype=$HTTP_POST_VARS;
these are...
|
by: nadomt |
last post by:
Happy friday to all!
I am getting the below error when visiting my user filter page.
i have gone to line 68, but cant see what the problem is...can anyone assist? advanced THANK YOU!
Error: E_NOTICE
URL: http://mysite.com/admin/users_filter.php
File: /home1/mysite/public_html/admin/users_filter.php
Line: 68
|
by: furqi |
last post by:
hi i am actually having problem in this code i am trying to check the value in the if condition in the very last lines of the code but i am facing an error of "undefined index" can anybody tell me so that i can solve my problem.
<html>
<body>
<form method="GET" action="switchcases.php">
<input type='text' name='furqan' >
<?php...
|
by: mediator |
last post by:
Hello I have a php contact email form on my a ecommerce shop website !
I am getting a Undefined index error messages coming from the top of the php code, the email form its self works fine,
HERE IS THE ERROR MESSAGES
Notice: Undefined index: Name in E:\domains\t\tools2diy.co.uk\user\htdocs\contact.php on line 13
Notice: Undefined...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |