php - Multifunctional button -


i have problem posting text fields , uploading picture @ same time, @ moment can either upload picture or post text fields. how can post @ same time using 1 button?

$photo_form  = '<form id="photo_form" enctype="multipart/form-data" method="post" action="php_parsers/status_system.php">'; $photo_form .=   '<select name="gallery" required>'; $photo_form .=     '<option value="cover">cover</option>'; $photo_form .=   '</select>'; $photo_form .=   ' &nbsp; &nbsp; &nbsp; <b>browse:</b> '; $photo_form .=   '<input type="file" name="photo" accept="image/*" required>'; $photo_form .=   '<p><input type="submit" value="upload"></p>'; $photo_form .= '</form>';  $status_ui = ""; $status_ui = '<div><textarea id="statustext" onkeyup="statusmax(this,500)" placeholder="description field"></textarea>'; $status_ui .= $photo_form; $status_ui .= '<textarea id="statustext2" onkeyup="statusmax(this,200)" placeholder="description field 2."></textarea></div>'; $status_ui .= '<button id="statusbtn" onclick="posttostatus(\'status_post\',\'a\',\''.$u.'\',\'statustext\',\'statustext2\')">post</button>'; 

to maximus2012

$status_ui  = ""; $status_ui .= '<div><textarea id="statustext" name="statustext" onkeyup="statusmax(this,500)"   placeholder="description field"></textarea>'; $status_ui .= '<textarea id="statustext2" name="statustext2" onkeyup="statusmax(this,200)" placeholder="description field 2."></textarea></div>';  $photo_form  = '<form id="photo_form" enctype="multipart/form-data" method="post"     action="php_parsers/status_system.php">'; $photo_form .=   '<select name="gallery" required>'; $photo_form .=     '<option value="cover">cover</option>'; $photo_form .=   '</select>'; $photo_form .=   ' &nbsp; &nbsp; &nbsp; <b>browse:</b> '; $photo_form .=   '<input type="file" name="photo" accept="image/*" required>'; $photo_form .=   $status_ui ; $photo_form .=   '<p><input type="submit" value="upload"></p>'; $photo_form .= '</form>';  echo $photo_form ; 

i can still upload image code when use

$photo_form .= '<p><button id="statusbtn" onclick="posttostatus(\'status_post\',\'a\',\''.$u.'\',\'statustext\',\'statustext2\')">post</button></p>'; 

instead of

$photo_form .= '<p><input type="submit" value="upload"></p>'; 

everything processed text parts insterted in 1 row , image in another.

this posttostatus function:

function posttostatus(action,type,user,ta,te){ var data = _(ta).value; var data2= _(te).value; if(data == "" && data2 == ""){ alert("please fill in fields"); return false; } 

i made adjustments image parsing script text , image placed in same row, since image uploaded after text, instead of inserting filename new row script updating last row created user on profile. need prevent posting form if of fields blank.

$sql = "update status set filename = '$db_file_name' author = '$log_username' && account_name = '$log_username' order id desc limit 1"; 

your text field , picture field not part of same form. see if works:

$status_ui  = ""; $status_ui .= '<div><textarea id="statustext" name="statustext" onkeyup="statusmax(this,500)"   placeholder="description field"></textarea>'; $status_ui .= '<textarea id="statustext2" name="statustext2" onkeyup="statusmax(this,200)" placeholder="description field 2."></textarea></div>';  $photo_form  = '<form id="photo_form" enctype="multipart/form-data" method="post"     action="php_parsers/status_system.php">'; $photo_form .=   '<select name="gallery" required>'; $photo_form .=     '<option value="cover">cover</option>'; $photo_form .=   '</select>'; $photo_form .=   ' &nbsp; &nbsp; &nbsp; <b>browse:</b> '; $photo_form .=   '<input type="file" name="photo" accept="image/*" required>'; $photo_form .=   $status_ui ; $photo_form .=   '<p><input type="submit" value="upload"></p>'; $photo_form .= '</form>';  echo $photo_form ; 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -