Jump to content

program to PHP


Recommended Posts

1st of all I would like to say hi to everyone herem very good program you got here :mellow:, happy to be part of the community

now.. i'm trying to write a program that has an input box, and an edit box. The reason i'm doing this is becouse i want the users of my program to be able to register. Now, i got a HTML page that looks like:

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Registration</title>
</head>

<body>
<div style="text-align: center;">
<form method="POST" action="http://thisismysite/registration.php">
   <input type="text" name="subject" size="19"><br>
   <br>
   <textarea rows="9" name="message" cols="30"></textarea>
   <br>
   <br>
   <input type="submit" value="Submit" name="submit">
</form>
</div>
</body>
</html>

now this html sends data to my PHP:

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Registration</title>
</head>

<body>
<?php
if(isset($_POST['submit'])) {
$to = "mymail@site.com";
$subject = $_POST['subject'];
$message = $_POST['message'];
 
$body = "$name_field\n $message";
 
echo "Data has been submitted to $to!";
mail($to, $subject, $body);
} else {
echo "Error!";
}
?>
</body>
</html>

thats on my site server and it send me registration information to my e-mail, and all that works perfectly well. BUT :( (theres always a but), i was wondering if i can make a GUI that will do the same thing as the HTLM, but without it loging on any server or loading any html. so basicly i need a GUI that will send the data inserted in the boxes like the html to the PHP.Ive done something but dont know how to make it work like a HTML:

#include <GUIConstants.au3>
#include <INet.au3>


$GUI = GUICreate("Email Sender", 400, 279, -1, -1)
GUISetBkColor(0xFFFFFF)

$Subject = GUICtrlCreateInput("", 88, 32, 233, 21)

$Message = GUICtrlCreateEdit("", 88, 64, 233, 145)

$SEND_button = GUICtrlCreateButton("SEND", 176, 224, 73, 25, 0)
GUISetState(@SW_SHOW)



While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
                Case $Subject
                ;i want this variable to link to the PHP variable with the same name.
                Case $Message
                ;i want this variable to link to the PHP variable with the same name
                Case $SEND_button
                ;this is my send button that does the works :)
    EndSwitch
WEnd

Thank you all in advance for all your help.

Link to comment
Share on other sites

Check Helpfile for the rest. Its Pretty useful

#include <GUIConstants.au3>
#include <INet.au3>


$GUI = GUICreate("Email Sender", 400, 279, -1, -1)
GUISetBkColor(0xFFFFFF)
$Subject = GUICtrlCreateInput("", 88, 32, 233, 21)
$Message = GUICtrlCreateEdit("", 88, 64, 233, 145)
$SEND_button = GUICtrlCreateButton("SEND", 176, 224, 73, 25, 0)
GUISetState(@SW_SHOW)



While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $SEND_button
            Sendit()
    EndSwitch
WEnd

Func Sendit()
    $Subject1 = GUICtrlRead($Subject)  ;- Key is GuiCtrlRead    Use F1 for Quick Help
    $Message1 = GUICtrlRead($Message)


    $s_SmtpServer = "mysmtpserver.com.au"  ;-From Help
    $s_FromName = "My Name"
    $s_FromAddress = "From eMail Address"
    $s_ToAddress = "To eMail Address"

    $Response = _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $Subject1, $Message1)
    $err = @error

    If $Response = 1 Then
        MsgBox(0, "Success!", "Mail sent")
    Else
        MsgBox(0, "Error!", "Mail failed with error code " & $err)
    EndIf
EndFunc   ;==>Sendit
[Cheeky]Comment[/Cheeky]
Link to comment
Share on other sites

I'm not sure how mail became a factor...

You need to use the winhttprequest COM object.

Example:

http://www.autoitscript.com/forum/index.php?showtopic=74557&view=findpost&p=542401

Edited by weaponx
Link to comment
Share on other sites

I'm not sure how mail became a factor...

You need to use the winhttprequest COM object.

Example:

http://www.autoitscript.com/forum/index.php?showtopic=74557&view=findpost&p=542401

Gui name was Email Sender so I figured it was going that direction... :mellow:

[Cheeky]Comment[/Cheeky]
Link to comment
Share on other sites

i'm trying to explain what i want in this example. the "global variables" need to go from the script directly to the PHP. sorry for the confusion, but i dont know how to exactly explain what i want in english :mellow:

tnx again :(

============================== php

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Registration</title>
</head>

<body>
<?php
if(isset($_POST['submit'])) {
$to = "mymail@site.com";
$subject = $_POST['subject'];
$message = $_POST['message'];
 
$body = "$name_field\n $message";

?>
</body>
</html>

========================================


Global variables:

subject --- php
message --- php
submit  --- php



html form --

<form method="POST" action="http://thisismysite/registration.php">
   <input type="text" name="subject" size="19"><br>
   <br>
   <textarea rows="9" name="message" cols="30"></textarea>
   <br>
   <br>
   <input type="submit" value="Submit" name="submit">
</form>


============================== au.3

#include <GUIConstants.au3>


$GUI = GUICreate("Email Sender", 400, 279, -1, -1)
GUISetBkColor(0xFFFFFF)

$Subject = GUICtrlCreateInput("", 88, 32, 233, 21)

$Message = GUICtrlCreateEdit("", 88, 64, 233, 145)

$SEND_button = GUICtrlCreateButton("SEND", 176, 224, 73, 25, 0)
GUISetState(@SW_SHOW)



While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
                Case $Subject
            ; link to this var < subject --- php >
                Case $Message
            ; link to this var < message --- php >
                Case $SEND_button
            send --> action = "http://thisismysite/registration.php"
            ; link to this var < submit  --- php >
    EndSwitch
WEnd
========================================
Link to comment
Share on other sites

maybe check into tcp/ip functions in autoit. that might be the dirrection you want to go.

**edit**

it's under network management in the help file

Edited by kaotkbliss

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...