Modify form input value on submit
<p>I wasn't sure how to phrase the title, but here's what I'm trying to do.</p>

<p>I have a form to login to webmail, I don't have access to the webmail - it just posts the form input to the website and the webmail server takes it from there.</p>

<p>Everyone logging in to this page will be using the same email extension (e.g. "@myemail.com"), so I want to save the hassle of typing that every time, instead they can just write "mike" and the form will add "@myemail.com" on it's own.</p>

<p>I could post this form to a middle ground php page that sticks "mike" + "@mymail.com" together and posts this info to the webmail?</p>

<p>Or is there a simpler way to do this without having to create another page?</p>

<pre><code>&lt;form name="loginForm" action="http://webmail.emailsrvr.com/login.php" method="POST" target="_blank"&gt;
&lt;input type="hidden" name="js_autodetect_results" value="SMPREF_JS_OFF"&gt;
&lt;input type="hidden" name="just_logged_in" value="1"&gt;
&lt;input type="hidden" name="type" value="v3"&gt;
&lt;input type="hidden" name="useSSL" id="useSSL" value=""&gt;

&lt;input type="email" name="user_name" placeholder="Username" required autofocus&gt;
&lt;input type="password" name="password" placeholder="Password" required&gt;

&lt;label for="remember"&gt;&lt;input type="checkbox" name="remember"&gt;Remember my info&lt;/label&gt;
&lt;button type="submit"&gt;Sign In&lt;/button&gt;

&lt;/form&gt;
</code></pre>

<p>I want to take the value entered here...</p>

<pre><code>&lt;input type="email" name="user_name" placeholder="Username" required autofocus&gt;
</code></pre>

<p>...and add an extension like "@myemail.com" to it, then post it.</p>

<p>Any idea? Thanks in advance for your help.</p>

<hr>

<p>I could do something like this?</p>

<p>PAGE 1 - Enter username and password...</p>

<pre><code>&lt;input type="text" name="send_email" placeholder="Username" required autofocus&gt;
&lt;input type="password" name="send_password" placeholder="Password" required&gt;

&lt;label for="remember"&gt;&lt;input type="checkbox" name="remember"&gt;Remember my info&lt;/label&gt;
&lt;button type="submit"&gt;Sign In&lt;/button&gt;
&lt;/form&gt;
</code></pre>

<p>PAGE 2 - PHP takes username and adds "@myemail.com" and sends form...</p>

<pre><code>&lt;?php
    $form_email = $form_password = "";

    if (!empty($_POST['send_email']) &amp;&amp; !empty($_POST['send_password'])) { 
        $form_email = $test($_POST['send_email']) . '@fountaincreations.ca';
        $form_password = $test($_POST['send_password']); 

        echo '&lt;form name="loginForm" action="http://webmail.emailsrvr.com/login.php" method="POST" target="_blank"&gt;';
        echo '&lt;input type="hidden" name="js_autodetect_results" value="SMPREF_JS_OFF"&gt;';
        echo '&lt;input type="hidden" name="just_logged_in" value="1"&gt;';
        echo '&lt;input type="hidden" name="type" value="v3"&gt;';
        echo '&lt;input type="hidden" name="useSSL" id="useSSL" value=""&gt;';
        echo '&lt;input type="hidden" name="user_name" value="' . $form_email . '"&gt;';
        echo '&lt;input type="hidden" name="form_password" value="' . $form_password . '"&gt;';
        echo '&lt;/form&gt;';
    } else { 
        echo '&lt;p style="text-align:center;padding:40px 20px;"&gt;Please go back and try again.&lt;/p&gt;';
    }

    function test($data) {
        $data = strtolower(data);
        $data = trim($data);
        $data = stripslashes($data);
        $data = htmlspecialchars($data);
        return $data;
    }
?&gt;
</code></pre>

<p>How do I tell PHP to automatically submit the form though?</p>

<hr>

<p>Here's what I have if I were to use jQuery:</p>

<p>It doesn't currently work though.</p>

<p>HTML:</p>

<pre><code>&lt;div class="box top"&gt;
&lt;form name="loginForm" action="http://webmail.emailsrvr.com/login.php" method="POST" target="_blank"&gt;
&lt;input type="hidden" name="js_autodetect_results" value="SMPREF_JS_OFF"&gt;
&lt;input type="hidden" name="just_logged_in" value="1"&gt;
&lt;input type="hidden" name="type" value="v3"&gt;
&lt;input type="hidden" name="useSSL" id="useSSL" value=""&gt;
  &lt;div class="inner"&gt;
    &lt;div class="inner-row"&gt;&lt;input type="text" name="user_name" placeholder="First Name" required autofocus&gt;&lt;/div&gt;
    &lt;div class="inner-row"&gt;&lt;input type="password" name="password" placeholder="Password" required&gt;&lt;/div&gt;
    &lt;div class="inner-row"&gt;
        &lt;div class="inner-col col-2-4"&gt;&lt;label for="remember"&gt;&lt;input type="checkbox" name="remember"&gt;Remember my info&lt;/label&gt;&lt;/div&gt;
        &lt;div class="inner-col col-2-4"&gt;&lt;button type="submit"&gt;Sign In&lt;/button&gt;&lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/form&gt;
&lt;/div&gt;
&lt;div class="box bottom"&gt;
    &lt;div class="inner"&gt;
        &lt;div class="inner-row"&gt;&lt;p&gt;Already signed in? &lt;a href="http://webmail.emailsrvr.com/a/webmail.php" target="_blank"&gt;&lt;b&gt;Go to your inbox.&lt;/b&gt;&lt;/a&gt;&lt;/p&gt;
    &lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>JS:</p>

<pre><code>&lt;script type="text/javascript"&gt;
  $(document).ready(function(){
    $("button[type='submit']").on('click', function(e){
        e.preventDefault();
        var userEmail = $.trim($("input[name='user_name']").val());
        $("input[name='user_name']").val(userEmail+"@fountaincreations.ca");
        $("form[name='loginForm']").submit();
    });
  }); 
&lt;/script&gt;
</code></pre>