• 11

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

Is there a way to use GET and POST together?

I need to pass some data with these 2 methods together ( GET AND POST ). I write this method, but I don't know if it is safe:

<form method="post" action="profile.php?id=<?php echo $_SESSION['id']; ?>" enctype="multipart/form-data">
<input type="text" size="40" name="title" >
<textarea name="description" rows="2" cols="30"></textarea>
<input id="starit" name="submit" value="Create" type="submit" />

a= $_GET['id'];
b= $_POST['title'];
c= $_POST['description'];

Is this code safe ? Or there are other ways to do that ?


This is not a combined GET and POST request; rather, it's a POST request with query parameters.

What you have written would be the right way. Always make sure that you get the expected fields:

if (isset($_GET['id'], $_POST['title'], $_POST['description']) {
  // go ahead

Btw, make sure that you escape your output:

<form method="post" action="profile.php?id=<?php echo rawurlencode($_SESSION['id']); ?>">

And if you're not uploading files, you don't need to set the enctype of your <form>.

  • 13
Reply Report

don't write method attribute in your form condition and add formmethod=" " attribute in input... for example:

<input type="submit" formmethod="get"  name="inputGet" value="updateGet" >
<input type="submit" formmethod="post" name="inputPost" value="updatePost" >
  • -1
Reply Report

Warm tip !!!

This article is reproduced from Stack Exchange / Stack Overflow, please click

Trending Tags

Related Questions