i'm working on an application that lets users enter the opening hours for a restaurant. i have the form code set up like this:
<div class="hourswrapper">
Days:
<input type="checkbox" name="day1[]" value="1" />M
<input type="checkbox" name="day1[]" value="2" />Tu
<input type="checkbox" name="day1[]" value="3" />W
<input type="checkbox" name="day1[]" value="4" />Th
<input type="checkbox" name="day1[]" value="5" />F
<input type="checkbox" name="day1[]" value="6" />Sa
<input type="checkbox" name="day1[]" value="7" />Su
<br />
Opening Time:
<select name="starthour1">
<option value="12">12</option>
<option value="01">1</option>
<option value="02">2</option>
<option value="03">3</option>
<option value="04">4</option>
<option value="05">5</option>
<option value="06">6</option>
<option value="07">7</option>
<option value="08">8</option>
<option value="09">9</option>
<option value="10">10</option>
<option value="11">11</option>
</select> :
<select name="startminute1">
<option value="00">00</option>
<option value="15">15</option>
<option value="30">30</option>
<option value="45">45</option>
<option value="59">59</option>
</select>
<select name="startwhen1">
<option value="am">am</option>
<option value="pm">pm</option>
</select><br />
Closing Time:
<select name="endhour1">
<option value="12">12</option>
<option value="01">1</option>
<option value="02">2</option>
<option value="03">3</option>
<option value="04">4</option>
<option value="05">5</option>
<option value="06">6</option>
<option value="07">7</option>
<option value="08">8</option>
<option value="09">9</option>
<option value="10">10</option>
<option value="11">11</option>
</select> :
<select name="endminute1">
<option value="00">00</option>
<option value="15">15</option>
<option value="30">30</option>
<option value="45">45</option>
<option value="59">59</option>
</select>
<select name="endwhen1">
<option value="am">am</option>
<option value="pm">pm</option>
</select><br />
<input type="checkbox" name="24hours[]" value="yes" />Open 24 Hours
</div>
so basically the person chooses a set of hours and marks which days those apply to. of course there might be multiple sets of hours (ex. if a restaurant is open 12-2 one day but 12-5 another). i'd like to have a "Add More Hours" button that duplicates this same code when pressed, however many times is necessary.
what's the best way to go about this? how do you dynamically add a form element without needing to have it hidden at the beginning? how do i set different numbered names for each set of hours inputs, and later know how many to access (using PHP post)? i assume i'll need a javascript function that keeps track of how many have been added.
alternatively, i am open to suggestions on how to present hours inputs differently/better, perhaps a way that doesn't require dynamic creation of form elements. i do want to restrict the user's inputs so i don't have to worry about parsing weird entries, which is why i don't want to just have an text input box for each day.
thanks.
Checkout http://www.w3schools.com/dom/dom_node.asp
Particularly the cloneNode and appendChild methods
Probably best to use JavaScript/JQuery to dynamically add new elements, then use foreach in your PHP script to process all the inputs?
Hope this helps.
Y.J.
Here's a quick little example of duplicating the hours input based on which checkbox is checked. Each hours div gets its' own unique id (see the attr('id',hrsDivID) part of the code below). Mimic this to rename your inputs/selects. See http://jquery.com/ and http://api.jquery.com/ for more.
<head>
<script type="text/javascript" src="/shared/javascript/jquery.js"></script>
</head>
<div id="hours" style='display:none'>
Opening Time:
<select name="starthour1">
<option value="12">12</option>
<option value="01">1</option>
<option value="02">2</option>
<option value="03">3</option>
<option value="04">4</option>
<option value="05">5</option>
<option value="06">6</option>
<option value="07">7</option>
<option value="08">8</option>
<option value="09">9</option>
<option value="10">10</option>
<option value="11">11</option>
</select> :
<select name="startminute1">
<option value="00">00</option>
<option value="15">15</option>
<option value="30">30</option>
<option value="45">45</option>
<option value="59">59</option>
</select>
<select name="startwhen1">
<option value="am">am</option>
<option value="pm">pm</option>
</select><br />
Closing Time:
<select name="endhour1">
<option value="12">12</option>
<option value="01">1</option>
<option value="02">2</option>
<option value="03">3</option>
<option value="04">4</option>
<option value="05">5</option>
<option value="06">6</option>
<option value="07">7</option>
<option value="08">8</option>
<option value="09">9</option>
<option value="10">10</option>
<option value="11">11</option>
</select> :
<select name="endminute1">
<option value="00">00</option>
<option value="15">15</option>
<option value="30">30</option>
<option value="45">45</option>
<option value="59">59</option>
</select>
<select name="endwhen1">
<option value="am">am</option>
<option value="pm">pm</option>
</select><br />
<input type="checkbox" name="24hours[]" value="yes" />Open 24 Hours
</div>
Days:
<div id='day1'>
<input type="checkbox" name="day1[]" value="1" onClick="addHours('day1');" >M
</div>
<div id='day2'>
<input type="checkbox" name="day1[]" value="2" onClick="addHours('day2');" />Tu
</div>
<div id='day3'>
<input type="checkbox" name="day1[]" value="3" onClick="addHours('day3');" />W
</div>
<div id='day4'>
<input type="checkbox" name="day1[]" value="4" onClick="addHours('day4');" />Th
</div>
<div id='day5'>
<input type="checkbox" name="day1[]" value="5" onClick="addHours('day5');" />F
</div>
<div id='day6'>
<input type="checkbox" name="day1[]" value="6" onClick="addHours('day6');"/>Sa
</div>
<div id='day7'>
<input type="checkbox" name="day1[]" value="7" onClick="addHours('day7');"/>Su
</div>
<script>
function addHours(divID){
var d = document.getElementById(divID);
var hrsDivID = divID+'_hours_div';
$('#hours').clone().attr('id',hrsDivID).css('display','').appendTo(d);
return false;
}
</script>
Related
I have a form where users have dropdowns.. The form have a get method so that the output values is used for processing.. But the problem is i get all the three values which is not able to be used..
<form method="get" action="finish.php">
<select name="case" >
<option value="">*Grimsborough Case*</option>
<option value="1" >001</option>
<option value="2" >002</option>
<option value="3" >003</option>
</select>
<select name="case" >
<option value="">*Pacific Bay Case*</option>
<option value="201" >PB01</option>
<option value="202" >PB02</option>
<option value="203" >PB03</option>
</select>
<select name="case" >
<option value="">*World Edition Case*</option>
<option value="301" >WE01</option>
<option value="302" >WE02</option>
<option value="303" >WE03</option>
</select>
These are the forms that I have the output while i select is something like this..
finish.php?case=&case=&case=302&submit=%3D%3D>+submit+<%3D%3D
I will like to get output like this
finish.php?case=302&submit=%3D%3D>+submit+<%3D%3D
Please help :)
You need to name your select elements differently
<form method="get" action="finish.php">
<select name="case1" >
<option value="">*Grimsborough Case*</option>
<option value="1" >001</option>
<option value="2" >002</option>
<option value="3" >003</option>
</select>
<select name="case2" >
<option value="">*Pacific Bay Case*</option>
<option value="201" >PB01</option>
<option value="202" >PB02</option>
<option value="203" >PB03</option>
</select>
<select name="case3" >
<option value="">*World Edition Case*</option>
<option value="301" >WE01</option>
<option value="302" >WE02</option>
<option value="303" >WE03</option>
</select>
And from your php script, you to do this:
$case1 = $_GET["case1"];
$case2 = $_GET["case2"];
$case3 = $_GET["case3"];
If i understood it right you want something like that:
<select name="case" >
<optgroup label="Grimsborough Case">
<option value="1" >001</option>
<option value="2" >002</option>
<option value="3" >003</option>
</optgroup>
<optgroup label="Pacific Bay Case">
<option value="201" >PB01</option>
<option value="202" >PB02</option>
<option value="203" >PB03</option>
</optgroup>
<optgroup label="World Edition Case">
<option value="301" >WE01</option>
<option value="302" >WE02</option>
<option value="303" >WE03</option>
</optgroup>
</select>
JSFiddle
I wanted to combine all 3 $_POST to 1 variable but the month day wont show up, how come?
Here is the code:
<div id="register-birth-date">
<input type="number" name="register-day" placeholder="DATE">
<select id="register-month">
<option value="00">Mouth</option>
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
<option value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
<input type="number" name=" " placeholder="YEARS">
</div>
$air_user_registered_date = $_POST['register-day']."/".$_POST['register-month']."/".$_POST['register-years'];
You need to add name attribute to both your select box for months and input box for years.
<div id="register-birth-date">
<input type="number" name="register-day" placeholder="DATE" />
<select name="register-month" id="register-month">
<option value="00">Mouth</option>
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
<option value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
<input type="number" name="register-years" placeholder="YEARS" />
</div>
JSFiddle
Date Text box given the name of "register-day".
Month Select box give the name of "register-month".
Year Text box give name of "register-years".
I have the current form:
<form name="estimate" action="live_preview.php" method="post"enctype="multipart/form-data">
<label for="file">Upload File 1:</label>
<input type="file" name="file" id="file"/>
<label for="qty1">Quantity:</label>
<select name="qty1">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
</select>
<br>
<label for="file">Upload File 2:</label>
<input type="file" name="file2" id="file2"/>
<label for="qty2">Quantity:</label>
<select name="qty2">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
</select>
<br>
<label for="file">Upload File 3:</label>
<input type="file" name="file3" id="file3"/>
<label for="qty3">Quantity:</label>
<select name="qty3">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
</select>
<br>
<label for="file">Upload File 4:</label>
<input type="file" name="file4" id="file4"/>
<label for="qty4">Quantity:</label>
<select name="qty4">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
</select>
<br>
<label for="file">Upload File 5:</label>
<input type="file" name="file5" id="file5"/>
<label for="qty5">Quantity:</label>
<select name="qty5">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
</select>
<br>
<br>
<label for="meterial">Meterial:</label>
<select name="material">
<option value="PLA">PLA (0.60$ / Gram)</option>
<option value="ABS">ABS (0.60$ / Gram)</option>
<option value="POLYCARB">PolyCarb (1.80$ / Gram)</option>
<option value="NYLON">Nylon (1.20$ / Gram)</option>
</select>
|
<label for="color">Color:</label>
<select name="color">
<option value="WHITE">White</option>
<option value="BLACK">Black</option>
<option value="RED">Red</option>
<option value="GREEN">Green</option>
<option value="GRAY">Gray</option>
</select>
|
<label for="delivery">Delivery Method:</label>
<select name="delivery">
<option value="PICK UP">Pick Up (Free)</option>
<option value="SHIPPED">Shipped (+10$)</option>
</select>
|
<label for="marketing">Marketing?</label>
<select name="marketing">
<option value="YES">YES</option>
<option value="NO">NO</option>
</select>
<br>
<label for="infill">Infill: 20%</label>
<input type="range" name="infill" id="infill" value="20" min="20" max="90" step="10" onchange="printValue('infill','rangeValue1')"/>
90%
<input id="rangeValue1" type="text" size="2"/>
<br>
<ul class="buttons vertical">
<input type="submit" class="button fit scrolly" name="submit" value="Refresh Estimate" />
</ul>
</form>
What I'm trying to do is:
Being able to limit the colour selection based on the type of material previously chosen
Upon submission, process php file while still keeping all fields populated so that if user isn't happy with price given, they can modify some settings and get a new "estimate"
have the following actions happen w/o a page refresh (not a priority)
Thank you very much for taking the time to read this! Its extremely appreciated.
1.
This would be achieved with client-side code. Javascript / jQuery is what you need here.
2.
Unfortunately, file fields can't be kept populated when you reload the page (or redirect back). You can keep them populated by using AJAX to send your form contents, but it can be quite complex and sending files with AJAX will only work in modern browsers.
3.
AJAX is what you are looking for if you want server actions to happen without a page refresh. Look at jQuery $.post. My suggestion is that you have your form which people begin to fill out. The site will check the inputs along the way and suggest prices without refreshing the page, and once they are happy and ready to go, they submit the form which will upload the files and "refresh the page".
on 2, php only solution: You can keep the fields populated on submission by adding a placeholder to the input field. The placeholder gets the submitted value ($_POST('value') or similar). Just make sure that the value isn't lost if you have several fields and thus several submits before the customer hits the final "all fine" button, maybe use $_SESSION for that.
Below is a snippet of the code I have created on a form page. The form inputs display the correct variables for $adjustedGrossIncome, $personalExemptions and the calculation for Tax Due Before Refundable Credits, but when I try to echo $birthYear the php dies. Any hints what I'm doing wrong?
<?php
$filingStatus = $_Post['filingStatus'];
$birthYear = $_Post['birthYear'];
$dependents = $_Post['dependents'];
$children = $_POST['children'];
$exemptions = $_POST['exemptions'];
$income = $_POST['income'];
$investments = $_POST['investments'];
$retirement = $_POST['retirement'];
$property = $_POST['property'];
$adjustedGrossIncome = $income + $investments + $retirement;
$personalExemptions = ($exemptions * 3950);
?>
<form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<fieldset style="width:500px;">
<legend>Filing Status</legend>
<p>
<label>
<input type="radio" name="filingStatus" value="married" id="filingStatus" />
Married filing jointly</label>
<br />
<label>
<input type="radio" name="filingStatus" value="single" id="filingStatus" />
Single or Head of Household</label>
</p>
</fieldset>
<p>
<label>Birth Year
<select name="birthYear" id="birthYear">
<option>Select Year</option>
<option value="1923">1923</option>
<option value="1924">1924</option>
<option value="1925">1925</option>
<option value="1926">1926</option>
<option value="1927">1927</option>
<option value="1928">1928</option>
<option value="1929">1929</option>
<option value="1930">1930</option>
<option value="1931">1931</option>
<option value="1932">1932</option>
<option value="1933">1933</option>
<option value="1934">1934</option>
<option value="1935">1935</option>
<option value="1936">1936</option>
<option value="1937">1937</option>
<option value="1938">1938</option>
<option value="1939">1939</option>
<option value="1940">1940</option>
<option value="1941">1941</option>
<option value="1942">1942</option>
<option value="1943">1943</option>
<option value="1944">1944</option>
<option value="1945">1945</option>
<option value="1946">1946</option>
<option value="1947">1947</option>
<option value="1948">1948</option>
<option value="1949">1949</option>
<option value="1950">1950</option>
<option value="1951">1951</option>
<option value="1952">1952</option>
<option value="1953">1953</option>
<option value="1954">1954</option>
<option value="1955">1955</option>
<option value="1956">1956</option>
<option value="1957">1957</option>
<option value="1958">1958</option>
<option value="1959">1959</option>
<option value="1960">1960</option>
<option value="1961">1961</option>
<option value="1962">1962</option>
<option value="1963">1963</option>
<option value="1964">1964</option>
<option value="1965">1965</option>
<option value="1966">1966</option>
<option value="1967">1967</option>
<option value="1968">1968</option>
<option value="1969">1969</option>
<option value="1970">1970</option>
<option value="1971">1971</option>
<option value="1972">1972</option>
<option value="1973">1973</option>
<option value="1974">1974</option>
<option value="1975">1975</option>
<option value="1976">1976</option>
<option value="1977">1977</option>
<option value="1978">1978</option>
<option value="1979">1979</option>
<option value="1980">1980</option>
<option value="1981">1981</option>
<option value="1982">1982</option>
<option value="1983">1983</option>
<option value="1984">1984</option>
<option value="1985">1985</option>
<option value="1986">1986</option>
<option value="1987">1987</option>
<option value="1988">1988</option>
<option value="1989">1989</option>
<option value="1990">1990</option>
<option value="1991">1991</option>
<option value="1992">1992</option>
</select>
</label>
</p>
<p>
<label>Number of Dependents (not including taxpayer and spouse if applicable
<input type="text" name="dependents" id="dependents" />
</label>
</p>
<p>
<label>Number of Children under 18
<input type="text" name="children" id="children" />
</label>
</p>
<p>
<label>Total number of exemptions
<input type="text" name="exemptions" id="exemptions" />
</label>
</p>
<p>
<label>Total Wages/Salary
<input type="text" name="income" id="income" />
</label>
</p>
<p>
<label>Investment income (interest, dividends, capital gains)
<input type="text" name="investments" id="investments" />
</label>
</p>
<p>
<label>Retirement income (pension, IRA, 401(k), etc.)
<input type="text" name="retirement" id="retirement" />
</label>
</p>
<p>
<label>Annual property taxes paid on primary residence and/or annual rent
<input type="text" name="property" id="property" />
</label>
</p>
<p>
<input type="submit" name="submit" id="submit" value="Calculate Net Tax Liability for 2013" />
<input type="reset" name="reset" id="reset" value="Reset Form" onClick="window.location.reload()" />
</p>
</form>
<p>Adjusted Gross Income: $<?php echo($adjustedGrossIncome); ?></p>
<p>Personal Exemptions: $<?php echo($personalExemptions); ?></p>
<p>Tax Due Before Refundable Credits: $<?php echo(($adjustedGrossIncome - $personalExemptions) * .0425); ?></p>
<p><?php echo($birthYear); ?></p>
Change all $_Post to uppercase $_POST
This is known as a superglobal and must be in uppercase.
More on superglobals can be found on the PHP.net Web site
http://php.net/manual/en/language.variables.superglobals.php
I have a script in PHP where I need to detect which button was pressed in a HTML page. I have found lots of similar questions asked by other people, but I am having problems.
HTML
<form method="post" action="kode/kode_newsletter_operation.php" id="newsletter_step3Form">
<p>
<label>Schedule newsletter:</label>
<select name="send_date_month" id="send_date_month">
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
<option value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
-
<select name="send_date_day" id="send_date_day">
<option value="01">1</option>
<option value="02">2</option>
<option value="03">3</option>
<option value="04">4</option>
<option value="05">5</option>
<option value="06">6</option>
<option value="07">7</option>
<option value="08">8</option>
<option value="09">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
-
<select name="send_date_year" id="send_date_year">
<option value='2012'>2012</option><option value='2013'>2013</option> </select>
<select name="send_date_hour" id="send_date_hour">
<option value="00">0</option>
<option value="01">1</option>
<option value="02">2</option>
<option value="03">3</option>
<option value="04">4</option>
<option value="05">5</option>
<option value="06">6</option>
<option value="07">7</option>
<option value="08">8</option>
<option value="09">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
</select>:<select name="send_date_min" id="send_date_min">
<option value="00">00</option>
<option value="00">05</option>
<option value="10">10</option>
<option value="00">15</option>
<option value="20">20</option>
<option value="00">25</option>
<option value="30">30</option>
<option value="00">35</option>
<option value="40">40</option>
<option value="00">45</option>
<option value="50">50</option>
<option value="00">55</option>
</select>
<div>Server Time: October 12, 2012 04:54</div>
</p>
<p>
<label for="send_date">Preview in Email:</label>
<input type="text" id="preview_email" value="" name="preview_email" />
<input type="button" id="preview_btn" name="preview_btn" class="btn btn_red" onclick="previewSendMail(1)" value="Send Preview"/>
</p>
<p> </p>
<div id="kode_result"></div>
<div id="content_buttons">
<input type="button" class="btn btn_blue big" name="goback" value="Last Step" onclick="window.location.href='./newsletter_create_step2.php?id=1'" />
<input type="submit" name="submit_btn_now" value="Send now!" class=" btn btn_red big"/>
<input type="submit" name="submit_btn" value="Schedule" class=" btn btn_green big"/>
<input name="action" type="hidden" value="newsletter_step3" />
<input type="hidden" name="newsletter_id" id="newsletter_id" value="1"/>
</div>
</form>
PHP
print_r($_POST);
Output
Array(
[send_date_month] => 10
[send_date_day] => 12
[send_date_year] => 2012
[send_date_hour] => 01
[send_date_min] => 50
[preview_email] =>
[action] => newsletter_step3
[newsletter_id] => 1
)
Both buttons are inside the <form> tag but the $_POST array doesn't include any info about them. What am I doing wrong? Do the most recent browsers send no information about the submit button or am I missing something?
I have no skills in javascript to develop a workaround for this, I only know PHP.
Thanks in advance.
Give the submit buttons the same name attribute, but with different values, then you can test against the text that is used on the submit button.
<pre><? print_r($_POST);?></pre>
<form method="post">
<input type="submit" name="button" value="AAA">
<input type="submit" name="button" value="BBB">
</form>
Ouput:
Array
(
[button] => AAA
)
Edit: Actually, I see nothing wrong with your code?
<pre><? print_r($_POST);?></pre>
<form method="post">
<input type="submit" name="submit_btn_now" value="Send now!" class=" btn btn_red big"/>
<input type="submit" name="submit_btn" value="Schedule" class=" btn btn_green big"/>
</form>
Output only clicking one:
Array
(
[submit_btn_now] => Send now!
)
Do you have JQuery or any other JS libraries running on your form? They tend to take over the submit event and thus the submit doesn't come from the actual submit input. Try it without a js library?
EDIT: Here is a work around:
$('#submit_btn_now').on('click', function() {
var hiddensubmit=document.createElement('input');
hiddensubmit.value = this.value;
hiddensubmit.name = this.name;
hiddensubmit.setAttribute('hidden','hidden');
$('#newsletter_step3Form').append(hiddensubmit);
$('#newsletter_step3Form').submit()
return false;
});
If you want to use the same value for all buttons (as it is the value that is shown as text) you could use the name attribute as information holder and prefix it. The way to get the value is then:
$information = substr(
end(
array_filter(
array_keys($_REQUEST),
function ($key) { return substr($key, 0, strlen(PREFIX)) == PREFIX; }
)
),
strlen(PREFIX)
);
Set both buttons' name attribute to the same value.Give each button a different value attribute, like so:
<input type="submit" name="submit" value="Log In">
<input type="submit" name="submit" value="Sign Up">
Then you can use an if statement in your php, like so:
if ($_POST['submit']=="Log In") {}
else {} // ELSE DETECTS THE "Sign Up" BUTTON, OR ANY OTHER BUTTON WITH A DIFFERENT VALUE
I think this pretty much gives you exactly the answer you were looking for: A way to detect which button was pressed using just PHP and no JavaScript.