-2

I'm having issues geting my form to submit correctly. I have successfully used code almost exactly like this one, but i can't seem to find the issue. It keeps saying 'undefined index' on every index that comes from my form's page except $subject=$_POST['subject'];. I have included both my form and php script, can anyone see the issue?

<form name="support" id="support" method="post" action="process.php">
    <input type="text" value="Name" name="name" id="name" /> <br/>
    <select name="subject" name="subject" id="subject">
        <option value="Suggestion">Suggestion</option>
        <option value="Website Error">Website Error</option>
        <option value="Forums">Forums</option> 
        <option value="Error 404">Error 404</option> 
        <option value="Other">Other</option> 
    </select> <br/> 
    <textarea rows="10" cols="40" name="content" id="Content">Please type your message here!</textarea> <br/> 
    <input type hidden value="<br/>" name="br" id="br" /> 
    <input type hidden value="<p>" name="sp" id="sp" /> 
    <input type hidden value="</p>" name="ep" id="ep" /> 
    <input type hidden value='<link rel="stylesheet" type="text/css" href="/css/layout.css">' name="css" id="css" /> 
    <input type hidden value="<h1>Support Ticket" name="head" id="head" /> 
    <input type hidden value='<script src="/scripts/copyright.js"></script>' name="copy" id="copy" /> 
    <input type hidden value="Status: Not View" name="stat" id="stat"/> 
    <input type="submit" name="s1" id="s1" value="Submit"> 
</form>

<? 
$name=$_POST['name']; 
$subject=$_POST['subject']; 
$con=$_POST['content']; 
$br=$_POST['br']; 
$sp=$_POST['sp']; 
$ep=$_POST['ep']; 
$css=$_POST['css']; 
$head=$_POST['head']; 
$copy=$_POST['copy']; 
$stat=$_POST['stat']; 
$stamp=date("jS \of F Y h:i:s A"); 
$ran=rand(1000000,9999999); 
$fp=fopen("tickets/$ran.html","a");
$savestring=$css.$head.$sp.$name." - ".$subject." - ".$con." - Ticket# ".$ran.$br.$stat.$br."Submitted: ".$stamp.$ep.$copy; 
fwrite($fp,$savestring); 
fclose($fp); 
echo"<p>Thank you $name!</p>"; 
echo "<p>Your Ticket Number# $ran</p>"; 
echo "<p>Submitted: $stamp</p>" 
?>
Phil
  • 157,677
  • 23
  • 242
  • 245
Davie
  • 55
  • 1
  • 8
  • 5
    Sorry, but please format your code properly (start with indentation e.g.) - this is a mess. – kero Nov 28 '13 at 23:07
  • Yeah, I need to get better at that – Davie Nov 28 '13 at 23:08
  • 1
    You have `name="subject" name="subject"` written twice, remove one. Also make sure short tags are set to "ON". – Funk Forty Niner Nov 28 '13 at 23:11
  • 1
    `` — what on earth is this?? If you must include `<` and `>`, use `<` and `>` – r3mainer Nov 28 '13 at 23:13
  • possible duplicate of [PHP: "Notice: Undefined variable" and "Notice: Undefined index"](http://stackoverflow.com/questions/4261133/php-notice-undefined-variable-and-notice-undefined-index) – Phil Nov 28 '13 at 23:14
  • There on, and although I did miss that mistake (thankyou btw) that's ironically the only only on not getting an 'undefined index' notice – Davie Nov 28 '13 at 23:15
  • This I why my code is sloppy. I don't have internet on my computer right now. I'm running wamp server locally on my WiFi. I made a txt file containing my code, accessed it with my phone nd copied nd pasted it here. My html looks incorrect, but the spaces are where the correct symbols should be. That being said, can anyone see my issue? – Davie Nov 28 '13 at 23:26

1 Answers1

2

Your code is a mess - if your format it properly, you notice maybe, your html code has errors

i.e.

<input type hidden value="</p>" name="ep" id="ep"/>

i think, you mean something like

<input type="hidden" value="&lt;/p&gt;" name="ep" id="ep"/>

also you should use <?php instead of <?, because the short syntax is disabled on many servers.

Btw. your code works in current version if chrome - so I think, its because your html syntax. If you clean your mess up, it should work on every browser

Philipp
  • 15,377
  • 4
  • 35
  • 52
  • "_also you should use `<` – davidkonrad Nov 28 '13 at 23:17
  • That was a copy nd paste issue, my html doesn't say that. Sorry, I'm on a cheep phone – Davie Nov 28 '13 at 23:20
  • @davidkonrad why? The current default value for `short_open_tag` is 1, but i times of earlier versions(i.e. 5.3) this wasn't the case.. ok, I shouldn't say on most servers, but on many – Philipp Nov 28 '13 at 23:25
  • "_The current default value for short_open_tag is 1_", yeah, meaning it is allowed. I havent seen any server yet, that didnt accepted ` ?>`, and I have seen a lot of PHP-servers over the past 10 years, and installed a lot of servers myself. – davidkonrad Nov 28 '13 at 23:33
  • As said, Im not the only one facing this problem with earlier versions.. try to google `php 5.3 short tags` – Philipp Nov 28 '13 at 23:37
  • I figured it out, I needed to enable 'zlib output compression' – Davie Nov 28 '13 at 23:42