I am working on this project which is going fine so far, however I have this one problem which I simply can't see how to solve.
I am having a section on a page where you can edit your information.
II am checking for $_POST on the same page to avoid redirecting the site, however it seems like the submit button aren't submitting anything.
EDIT: I DON'T get any PHP error, nothin simply happens when I press the submit button.
My PHP on the same page as the form:
require_once("inc/functions.php");
if(isset($_POST['saveButton'])){
$emailValue = mysql_real_escape_string($_POST['email']);
$bukserValue = mysql_real_escape_string($_POST['bukser']);
$jakkeValue = mysql_real_escape_string($_POST['jakke-str']);
$skoValue = mysql_real_escape_string($_POST['shoes']);
setUserSetting($emailValue, $bukserValue, $jakkeValue, $skoValue);
};
My PHP function:
function setUserSetting($emailValue, $bukserValue, $jakkeValue, $skoValue) {
$emailValue = strip_tags($emailValue);
$uid = $_SESSION['usrId'];
$sql = "UPDATE usr SET email='$emailValue', sko='$skoValue', jakke='$jakkeValue', bukser='$bukserValue' WHERE id='$uid'";
$result=mysql_query($sql);
if($result === FALSE) {
die(mysql_error());
} else {
$_SESSION['usrEmail'] = $emailValue;
return "gemt";
};
};
And finally my html form:
<section id="settings" class="bg-light-gray">
<div class="container">
<div class="row">
<div class="col-lg-12 text-center">
<h2 class="section-heading">Indstillinger</h2>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<form class="form-horizontal" action="#" method="post" role="form" name="settForm">
<fieldset>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="email">E-mail</label>
<div class="col-md-4">
<input id="email" name="email" type="text" placeholder="E-mail" class="form-control input-md" value="<? echo getUserSetting($usrEmail, 'mail'); ?>">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label" for="bukser">Bukser størrelse</label>
<div class="col-md-4">
<select id="bukser" name="bukser" class="form-control">
<option value="C44">C44</option>
<option value="C46">C46</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label" for="jakke-str">Jakke størrelse</label>
<div class="col-md-4">
<select id="jakke-str" name="jakke-str" class="form-control">
<option value="XS">XS</option>
<option value="S">S</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label" for="shoes">Sko størrelse</label>
<div class="col-md-4">
<select id="shoes" name="shoes" class="form-control">
<option value="36">36</option>
<option value="37">37</option>
</select>
</div>
</div>
</fieldset>
<button type="submit" class="btn btn-xl text-center center-block" id="saveButton" name="saveButton">Gem ændringer</button>
</form>
</div>
</div>
</div>