0

I am trying to implement the creating topic part in forum

Why I can't use the another php file, say b.php to get data that sent from a.php?

$topic=$_POST['title'];
$detail=$_POST['content'];
$name=$_POST['username'];

Errors show message that undefined index at these 3 inputs.

2
  • Post source from b.php and a.php. Your question is far too vague. Show us how the form is submitted. Commented Jul 28, 2011 at 7:54
  • What do you mean you can't use? If the code above is your b.php I don't see any reason why you can't make such post on it. <form action='b.php' method='post'> Commented Jul 28, 2011 at 7:56

1 Answer 1

3

Because you are calling this script without sending POST data.

Use it in following way:

$topic  = empty($_POST['title'])  ? null : $_POST['title'];
$detail = empty($_POST['detail']) ? null : $_POST['detail'];
$name   = empty($_POST['name'])   ? null : $_POST['name'];

It will avoid errors and if you just request script without POSTing, variables will contain null values

Sign up to request clarification or add additional context in comments.

2 Comments

But the problem is when I submit these information, there is no even u-date to databse and my b.php cannot help me add the topic since they check the input field is null.
used, but not sure why the array is empty even I have submit the information at a.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.