Problem with form submission

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tr33m4n
Forum Newbie
Posts: 5
Joined: Mon Oct 13, 2008 9:44 am
Location: Derbyshire, UK

Problem with form submission

Post by tr33m4n »

Hello there,

I need help. Basically I have a form approximately like the following:

Code: Select all

<form name="loginform" id="loginform" action="action.php" method="post">
    <p>
        <label>Username<br /><br />
        <input type="text" name="log" id="user_login" class="textarea" value="" size="20" tabindex="10" /></label>
    </p>
    <p>
        <label>Password<br />
        <input type="password" name="pwd" id="user_pass" class="textarea" value="" size="20" tabindex="20" /></label>
 
    </p>
    <p class="forgetmenot"><label><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="90" /> Remember Me</label></p>
    <p class="submit">
        <input type="submit" class="sendbutton" name="wp-submit" id="wp-submit" value="Log In" tabindex="100" />
        <input type="hidden" name="redirect_to" value="index.php" />
        <input type="hidden" name="testcookie" value="1" />
</form>
Which does its job perfectly well. However I need this form to submit the same variables entered into the password and username fields to a different location but with different input names. This is because one of the scripts that will process the login I cannot edit and has pre-determined names for the data to be submitted to... if that makes sense. The other script thats going to process this data is my wordpress blog. basically i want a login form that will log me into, say my hosting account and my blog. Im rather new when it comes to php and can usually get by, however this has stumped me. Or if anyone knows how to edit the wordpress login system to use the same form 'names' then that would be great also. Im sorry if im not making much sense :(

Many thanks

Dan
Blondy
Forum Commoner
Posts: 32
Joined: Thu Mar 06, 2008 5:55 pm

Re: Problem with form submission

Post by Blondy »

as easy as going to hell
just rename the name for below codes(-----) to wrdpress defaults.
and also it's html not php

Code: Select all

<input type="text" name="-----" id="user_login" class="textarea" value="" size="20" tabindex="10" />

Code: Select all

<input type="password" name="-----" id="user_pass" class="textarea" value="" size="20" tabindex="20" />
if your problem is something else lz describe more
oh I forgot for location
change the ----- to your address

Code: Select all

action="------"
tr33m4n
Forum Newbie
Posts: 5
Joined: Mon Oct 13, 2008 9:44 am
Location: Derbyshire, UK

Re: Problem with form submission

Post by tr33m4n »

Thanks for the help, but im aware that to log into worpdress id have to do this. However the form has to submit itself to 2 different locations, which I can code myself, however one of the locations requires the 'user name' and 'password' fields to have a different 'name' value. Also the code at this location does not have open code, therefore I cannot edit the php to set a uniform name for the 2 fields.

If anyone can help that would be greatly appreciated, or if anyone knows how to change the php in how wordpress handles its logins so that I can set the username and password field' name from say 'log' and 'pwd' to 'username' and 'password' that would also be greatly appreciated.

Thanks again
Dan
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: Problem with form submission

Post by omniuni »

Try checking out the curl function.

http://us2.php.net/manual/en/function.curl-exec.php

I believe you can use that to submit post data.

-OmniUni
Blondy
Forum Commoner
Posts: 32
Joined: Thu Mar 06, 2008 5:55 pm

Re: Problem with form submission

Post by Blondy »

this one is easy too
but not sure about what telling you
try sendng all data to worldpress file
change values to what worldpress needs try including the other script in world press file & changing the script file values to world press one
sincerely
Sarah
tr33m4n
Forum Newbie
Posts: 5
Joined: Mon Oct 13, 2008 9:44 am
Location: Derbyshire, UK

Re: Problem with form submission

Post by tr33m4n »

Unfortunately I cannot do this either as the 'closed source' script is being hosted on a different server and I have no access to it, other than http, so I cant combine the scripts really. Thankyou for the reply however!

Cheers
Dan
tr33m4n
Forum Newbie
Posts: 5
Joined: Mon Oct 13, 2008 9:44 am
Location: Derbyshire, UK

Re: Problem with form submission

Post by tr33m4n »

Any other ideas? (shameless bump :roll: )
Blondy
Forum Commoner
Posts: 32
Joined: Thu Mar 06, 2008 5:55 pm

Re: Problem with form submission

Post by Blondy »

so you need to post data 1.to your host 2.another server is that right?
so if it's righ you should use java I just am not sure about the other server anyway if your interested tell me so I have some scripts if you can modify them
tr33m4n
Forum Newbie
Posts: 5
Joined: Mon Oct 13, 2008 9:44 am
Location: Derbyshire, UK

Re: Problem with form submission

Post by tr33m4n »

Thanks for your reply. Ah right, javascript might be the way forward then. Would I be able to send the data to 1 location and then rename the input fields to be sent to the other?

Cheers

Dan
Blondy
Forum Commoner
Posts: 32
Joined: Thu Mar 06, 2008 5:55 pm

Re: Problem with form submission

Post by Blondy »

here I found something interesting!
http://www.webmasterworld.com/forum88/5375.htm
and also the ajax code

for html head

Code: Select all

<script type="text/javascript" src="ajax.js"></script>
<script type="text/javascript">
        function getScriptPage(div_id,status,more_options,act_id)
        {
            subject_id = div_id;
 
            status   = document.getElementById(status).value;
 
            switch(more_options)
            {
                case '1':
                {
                  http.open("GET", "script_page.php?val1=" + escape(content1)+"&val2=" + escape(content2)+"&val3=" + escape(content3), true);
                }
                break;
                case '2':
                {
                  http.open("GET", "script_page.php?delete=1&id=" + escape(act_id), true);
                }
                break;
                case '3':
                {
                  http.open("GET", "done.php?status=" + escape(status)+"&id=" + escape(act_id), true);
                }
                break;
            }
 
            http.onreadystatechange = handleHttpResponse;
            http.send(null);
 
            document.getElementById(content_id1).value ="";
            document.getElementById(content_id2).value="";
            document.getElementById(content_id3).value="";
 
        }
        function reset(content_id1,content_id2,content_id3)
        {
            document.getElementById(content_id1).value ="";
            document.getElementById(content_id2).value="";
            document.getElementById(content_id3).value="";
        }
 
</script>
 
//hint case 1 is what you want and it sends data to one location with special values
there should be no problem if you add another line for somewhere else location too

and for form

Code: Select all

    <div class="input-div">
    <TABLE border="0" class="CommentsofT" cellspacing=0 width="200px" cellpadding="5">
    <TR>
        <TD colspan="2"><strong>???????</strong></TD>
    </TR>
    <TR>
        <TD><strong>??? :</strong></TD>
        <TD align="left" class="commenthelpHed"><INPUT TYPE="text" NAME="name" id="s"></TD>
    </TR>
    <TR>
        <TD><strong>????? :</strong></TD>
        <TD align="left" class="commenthelpHed"><INPUT TYPE="text" NAME="email" id="text_content2"></TD>
    </TR>
    <TR>
        <TD><strong>????? :</strong></TD>
        <TD align="left" class="commenthelpHed"><TEXTAREA NAME="comment" ROWS="4" COLS="30" id="text_content3"></TEXTAREA></TD>
    </TR>
    <TR>
        <TD colspan="2" align="center" >
            <INPUT TYPE="submit" value="?????" onMouseUp="getScriptPage('output_div','s','text_content2','text_content3','1','x')">
            <INPUT TYPE="button" onClick="reset('text_content1','text_content2','text_content3')" value="Reset">
        </TD>
    </TR>
    </TABLE>
    </form>
    </div>
 
sorry dude you change it the way you want it
the language inside is persian and also the ajax file is included, don't add any "<form ...."

if you're interested to use my and my friend code plz add or name as hint thanks
"Sarah Aria"

the ajax.js

Code: Select all

 
    subject_id = '';
    function handleHttpResponse() {
        if (http.readyState == 4) {
            if (subject_id != '') {
                document.getElementById(subject_id).innerHTML = http.responseText;
            }
        }
    }
    function getHTTPObject() {
        var xmlhttp;
        /*@cc_on
        @if (@_jscript_version >= 5)
            try {
                xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (E) {
                    xmlhttp = false;
                }
            }
        @else
        xmlhttp = false;
        @end @*/
        if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
            try {
                xmlhttp = new XMLHttpRequest();
            } catch (e) {
                xmlhttp = false;
            }
        }
        return xmlhttp;
    }
    var http = getHTTPObject(); // We create the HTTP Object
Blondy
Forum Commoner
Posts: 32
Joined: Thu Mar 06, 2008 5:55 pm

Re: Problem with form submission

Post by Blondy »

if you've got problems on this code let me now
Post Reply