Setelah Membuat PHP MySQL Script creator menggunakan visual basic 2008 / vb.net bagian pertama selesai kemudian saya akan melanjutkan pembuatan program PHP Mysql script creator bagian kedua yaitu akan membahas tentang membuat script mysql Insert dan update dalam satu program.
Langsung saja ke proses Membuat PHP MySQL Script creator menggunakan visual basic 2008 / vb.net bagian ke dua buatlah satu form seperti pada artikel Membuat PHP MySQL Script creator menggunakan visual basic 2008 / vb.net bagian pertama lihat gambar dibawah:
Jika sudah seperti gambar diatas klik 2 kali formnya, hapus semua kode yang ada dan masukkan kode dibawah ini:
Maka ketika metode yang dipilih adalah Insert secara otomatis langkah selanjutnya adalah pembuatan script php mysql yang berhubungan dengan inserting data dan ketika metode yang dipilih adalah Update maka kode akan menjalankan pembuatan php mysql script yang berhubungan dengan updating data.Public Class Form1
Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged
If RichTextBox1.Text = "" Then
RichTextBox1.Text = "<?php" & vbNewLine
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
RichTextBox1.Text = RichTextBox1.Text & vbNewLine & "$konak=mysql_connect('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "');" & vbNewLine
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
RichTextBox1.Text = RichTextBox1.Text & "mysql_select_db('" & TextBox4.Text & "',$konak);" & vbNewLine
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If Not RichTextBox1.Text.Contains("mysql_connect") And ComboBox1.Text = "Insert" Then
RichTextBox1.Text = "<?php" & vbNewLine & "if isset($_POST['Submit'])){" & vbNewLine & "mysql_query(" & """Insert into "
TextBox5.Visible = True
Button3.Visible = True
ElseIf Not RichTextBox1.Text.Contains("mysql_connect") And ComboBox1.Text = "Update" Then
RichTextBox1.Text = "<?php" & vbNewLine & "$id2=$_GET['id'];" & vbNewLine & " if (isset($_GET['id'])){" & vbNewLine & "if isset($_POST['Submit'])){" & vbNewLine & "mysql_query(" & """Update "
TextBox5.Visible = True
Button3.Visible = True
TextBox6.Visible = False
ElseIf RichTextBox1.Text.Contains("mysql_connect") And ComboBox1.Text = "Insert" Then
RichTextBox1.Text = RichTextBox1.Text & "if isset($_POST['Submit'])){" & vbNewLine & "mysql_query(" & """Insert into "
TextBox5.Visible = True
Button3.Visible = True
ElseIf RichTextBox1.Text.Contains("mysql_connect") And ComboBox1.Text = "Update" Then
RichTextBox1.Text = RichTextBox1.Text & "$id2=$_GET['id'];" & vbNewLine & " if (isset($_GET['id'])){" & vbNewLine & "if isset($_POST['Submit'])){" & vbNewLine & "mysql_query(" & """Update "
TextBox5.Visible = True
Button3.Visible = True
TextBox6.Visible = False
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If ComboBox1.Text = "Insert" Then
RichTextBox1.Text = RichTextBox1.Text & TextBox5.Text & "("
Button3.Visible = False
Label6.Text = "Kolom"
Button4.Visible = True
ElseIf ComboBox1.Text = "Update" Then
RichTextBox1.Text = RichTextBox1.Text & " " & TextBox5.Text & " SET "
Button3.Visible = False
Label6.Text = "Kolom"
Button4.Visible = True
End If
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
If Label6.Text = "Kolom" And ComboBox1.Text = "Insert" Then
RichTextBox1.Text = RichTextBox1.Text & TextBox5.Text
TextBox5.Visible = False
TextBox6.Visible = True
Button4.Visible = False
Button5.Visible = True
Button6.Visible = True
ElseIf Label6.Text = "Kolom" And ComboBox1.Text = "Update" Then
RichTextBox1.Text = RichTextBox1.Text & TextBox5.Text & "='$_POST[" & TextBox5.Text & "]'"
RichTextBox2.Text = RichTextBox2.Text & "<form action='' method=''>" & vbNewLine & "<input name='" & TextBox5.Text & "'>"
TextBox5.Visible = False
TextBox6.Visible = True
Button4.Visible = False
Button5.Visible = True
Button6.Visible = True
Else
RichTextBox1.Text = RichTextBox1.Text & "'$_POST[" & TextBox5.Text & "]'"
RichTextBox2.Text = RichTextBox2.Text & "<form action='' method='POST'>" & vbNewLine & "<input name='" & TextBox5.Text & "'>"
TextBox5.Visible = False
TextBox6.Visible = True
Button4.Visible = False
Button5.Visible = True
Button6.Visible = True
End If
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
If Label6.Text = "Kolom" And RichTextBox1.Text.Contains("Insert") Then
RichTextBox1.Text = RichTextBox1.Text & "," & TextBox6.Text
ElseIf Label6.Text = "Values" And RichTextBox1.Text.Contains("Insert") Then
RichTextBox1.Text = RichTextBox1.Text & ",'$_POST[" & TextBox6.Text & "]'"
RichTextBox2.Text = RichTextBox2.Text & vbNewLine & "<input name='" & TextBox6.Text & "'>"
ElseIf Label6.Text = "Kolom" And RichTextBox1.Text.Contains("Update") Then
RichTextBox1.Text = RichTextBox1.Text & "," & TextBox6.Text & "='$_POST[" & TextBox6.Text & "]'"
RichTextBox2.Text = RichTextBox2.Text & vbNewLine & "<input name='" & TextBox6.Text & "'>"
End If
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
If Label6.Text = "Kolom" And RichTextBox1.Text.Contains("Insert") Then
RichTextBox1.Text = RichTextBox1.Text & ") values ("
Label6.Text = "Values"
TextBox6.Visible = False
Button5.Visible = False
TextBox5.Visible = True
Button4.Visible = True
ElseIf Label6.Text = "Values" And RichTextBox1.Text.Contains("Insert") Then
RichTextBox1.Text = RichTextBox1.Text & ")" & """);" & vbNewLine & "echo 'Sukses';" & vbNewLine & "}" & vbNewLine & "?>" & vbNewLine
RichTextBox2.Text = RichTextBox2.Text & vbNewLine & "<input name='Submit' value='Masuk' type='submit'>"
RichTextBox1.Text = RichTextBox1.Text & RichTextBox2.Text
RichTextBox2.Clear()
Button6.Visible = False
TextBox6.Visible = False
TextBox5.Visible = False
TextBox4.Visible = True
Button5.Visible = False
Button4.Visible = False
Button3.Visible = True
ElseIf Label6.Text = "Kolom" And RichTextBox1.Text.Contains("Update") Then
RichTextBox1.Text = RichTextBox1.Text & " where id=$id2"");" & vbNewLine & "}" & vbNewLine & "}" & vbNewLine & "?>"
RichTextBox2.Text = RichTextBox2.Text & vbNewLine & "<input name='Submit' value='Masuk' type='submit'>"
RichTextBox1.Text = RichTextBox1.Text & RichTextBox2.Text
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
0 comments:
Speak up your mind
Tell us what you're thinking... !